I have a user control library that will use as a custom tooltip for another window, the user control holds ImageSource of a imagebrush that reference to a directory . Inside the window, I have another class that will generate an image file to the directory same as the imagebrush.
However i get an error below after run. The call stack contained only external code. 'The invocation of the constructor on type 'WpfApplication2.MainWindow' that matches the specified binding constraints threw an exception.' Line number '4' and line position '9'
Here is my snippet.
UserControl1.xaml
<UserControl.Resources>
<Style TargetType="Rectangle">
<Setter Property="Fill">
<Setter.Value>
<ImageBrush ImageSource="C:\Users\user\Desktop\wpf\WpfApplication2\WpfApplication2\Images/QR.png" Stretch="Fill" />
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
DisplayWindow.xaml
xmlns:myToolTip="clr-namespace:WpfControlLibrary2;assembly=WpfControlLibrary2"
<myToolTip:UserControl1 Visibility="Collapsed" x:Name="customToolTip" Width="468" Height="700" />
QRCodeEncoder.cs
public QrCodeEncodercs(string encodeString)
{
QrEncoder qrEncoder = new QrEncoder(ErrorCorrectionLevel.H);
QrCode qrCode = new QrCode();
//const string encodeString = "123";
qrEncoder.TryEncode(encodeString, out qrCode);
Renderer renderer = new Renderer(11, System.Drawing.Brushes.Black, System.Drawing.Brushes.White);
renderer.CreateImageFile(qrCode.Matrix, @"C:\Users\user\Desktop\wpf\WpfApplication2\WpfApplication2\Images\QR.png\Images\QR.png",
ImageFormat.Png);
}
DisplayWindow.xaml.cs
When i run the constructor of the class above. The error mentioned above happened.
qce = new QrCodeEncodercs(videoName);
What happened actually? Any guidance? Thanks in advance.
Edit____InnerException
InnerException: System.Runtime.InteropServices.ExternalException
HResult=-2147467259
Message=A generic error occurred in GDI+.
Source=System.Drawing
ErrorCode=-2147467259
StackTrace:
at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
at Gma.QrCodeNet.Encoding.Windows.Controls.Renderer.CreateImageFile(BitMatrix matrix, String fileName, ImageFormat imageFormat)
at WpfApplication2.DisplayWindow.QrCodeEncodercs(String encodeString) in c:\Users\user\Desktop\wpf\KinectREAL\WpfApplication2\WpfApplication2\DisplayWindow..xaml.cs:line 127
at WpfApplication2.DisplayWindow.PopulateVideoListAndFirstVideo() in c:\Users\user\Desktop\wpf\KinectREAL\WpfApplication2\WpfApplication2\DisplayWindow..xaml.cs:line 157
at WpfApplication2.DisplayWindow..ctor() in c:\Users\user\Desktop\wpf\KinectREAL\WpfApplication2\WpfApplication2\DisplayWindow..xaml.cs:line 79
at WpfApplication2.MainWindow..ctor() in c:\Users\user\Desktop\wpf\KinectREAL\WpfApplication2\WpfApplication2\MainWindow.xaml.cs:line 45
InnerException: