|
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.ArgumentException: Parameter is not valid.
at System.Drawing.FontFamily.GetName(Int32 language)
at System.Drawing.FontFamily.get_Name()
at System.Windows.Forms.Internal.WindowsFont.FromFont(Font font, WindowsFontQuality fontQuality)
at System.Windows.Forms.Internal.WindowsGraphicsCacheManager.GetWindowsFont(Font font, WindowsFontQuality fontQuality)
at System.Windows.Forms.TextRenderer.DrawText(IDeviceContext dc, String text, Font font, Rectangle bounds, Color foreColor, TextFormatFlags flags)
at System.Windows.Forms.Label.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Label.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
BarcodeLabelGenerator
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Pro%20Data%20Doctor%20Barcode/Barcode%20Label%20Generator%20Software%20Demo/BarcodeLabelGenerator.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitdebugging="true">
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
|
|
|
|
|
Wow, a lot of info we didn't need, and no code.
Looks to me like you tried to load a font by name, and the name was invalid.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hello Sir,
I tried to load the font and font name is correct..
its running good but some time it give this error.....
|
|
|
|
|
Well, so long as you want to keep the code a secret, I can't hope to help you. Perhaps if you also told us how often it works, under what circumstances it fails, all the pertinent info you didn't put in your original post.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hello Sir,
All this thing happen when i use some other options of my application like changing color opening help file...
This is the font used to add fonts to my application
class PrivateFonts<br />
{<br />
[DllImport("Gdi32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]<br />
private static extern IntPtr AddFontMemResourceEx(IntPtr pbFont, int cbFont, int pdv, ref int pcFonts);<br />
public System.Drawing.Text.PrivateFontCollection GetFont(string[] FontResource)<br />
{<br />
string NameSpc = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name.ToString();<br />
System.IO.Stream FntStrm;<br />
System.Drawing.Text.PrivateFontCollection FntNc = new System.Drawing.Text.PrivateFontCollection();<br />
int i;<br />
for (i = 0; i <= FontResource.GetUpperBound(0); i++)<br />
{<br />
FntStrm = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(NameSpc + "." + FontResource[i]);<br />
byte[] ByteStrm = new byte[(int)FntStrm.Length];<br />
FntStrm.Read(ByteStrm, 0, Convert.ToInt32((int)FntStrm.Length));<br />
IntPtr FntPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(System.Runtime.InteropServices.Marshal.SizeOf(typeof(byte)) * ByteStrm.Length);<br />
System.Runtime.InteropServices.Marshal.Copy(ByteStrm, 0, FntPtr, ByteStrm.Length);<br />
FntNc.AddMemoryFont(FntPtr, ByteStrm.Length);<br />
Int32 pcFonts;<br />
pcFonts = 1;<br />
AddFontMemResourceEx(FntPtr, ByteStrm.Length, 0, ref pcFonts);<br />
System.Runtime.InteropServices.Marshal.FreeHGlobal(FntPtr);<br />
}<br />
return FntNc;<br />
}<br />
}
|
|
|
|
|
Which line blows up ? This looks super nasty, why do you need to do all this ? Are you loading fonts from your resources ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Yes i am loading fonts from resources
|
|
|
|
|
My other questions were 'why do you need to do that' and 'which line blows up'. How often does it blow up ? Can you reproduce it, and know it will blow up ( i.e. does it blow up every third time or something ) ? If you read your error message, it's telling you you have a name wrong. Have you tried making it so it doesn't require the exact name ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Sir it does not show any line of error it simply give a message that Parameter is not valid. and application closes.
but when i used to make a setup then and install it on the target machine then it give such a error that i have posted in starting about JIT..
|
|
|
|
|
Sir i fount the error in Program.cs in this line
Application.Run(new Form1());
Description:
{"Parameter is not valid."} {"Parameter is not valid."}
Source="System.Drawing"
Stack Trace
" at System.Drawing.FontFamily.GetName(Int32 language)\r\n at System.Drawing.FontFamily.get_Name()\r\n at System.Windows.Forms.Internal.WindowsFont.FromFont(Font font, WindowsFontQuality fontQuality)\r\n at System.Windows.Forms.Internal.WindowsGraphicsCacheManager.GetWindowsFont(Font font, WindowsFontQuality fontQuality)\r\n at System.Windows.Forms.TextRenderer.DrawText(IDeviceContext dc, String text, Font font, Rectangle bounds, Color foreColor, TextFormatFlags flags)\r\n at System.Windows.Forms.Label.OnPaint(PaintEventArgs e)\r\n at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)\r\n at System.Windows.Forms.Control.WmPaint(Message& m)\r\n at System.Windows.Forms.Control.WndProc(Message& m)\r\n at System.Windows.Forms.Label.WndProc(Message& m)\r\n at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)\r\n at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)\r\n at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)\r\n at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)\r\n at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)\r\n at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)\r\n at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)\r\n at System.Windows.Forms.Application.Run(Form mainForm)\r\n at BarcodeLabelGenerator.Program.Main() in E:\\DEMO VERSION\\BarcodeLabelGenerator\\BarcodeLabelGenerator\\Program.cs:line 18\r\n at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)\r\n at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)\r\n at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()\r\n at System.Threading.ThreadHelper.ThreadStart_Context(Object state)\r\n at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n at System.Threading.ThreadHelper.ThreadStart()"
|
|
|
|
|
Dixy wrote: Parameter is not valid
Dixy wrote: System.Drawing.FontFamily.GetName
This is where we started. Your font name is wrong.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Sir,
So how can i overcome from this problem.
as i have tried so many thing to solve this problem but its still there is no solution..
And i am using thia font
string[] fontNames = { "IDAutomationXC39M.ttf" };
|
|
|
|
|
Sir I am sending the code that i used and the error that comes
I am using this code to embded font:
class PrivateFonts<br />
{<br />
[DllImport("Gdi32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]<br />
private static extern IntPtr AddFontMemResourceEx(IntPtr pbFont, int cbFont, int pdv, ref int pcFonts);<br />
public System.Drawing.Text.PrivateFontCollection GetFont(string[] FontResource)<br />
{<br />
string NameSpc = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name.ToString();<br />
System.IO.Stream FntStrm;<br />
System.Drawing.Text.PrivateFontCollection FntNc = new System.Drawing.Text.PrivateFontCollection();<br />
int i;<br />
for (i = 0; i <= FontResource.GetUpperBound(0); i++)<br />
{<br />
FntStrm = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(NameSpc + "." + FontResource[i]);<br />
byte[] ByteStrm = new byte[(int)FntStrm.Length];<br />
FntStrm.Read(ByteStrm, 0, Convert.ToInt32((int)FntStrm.Length));<br />
IntPtr FntPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(System.Runtime.InteropServices.Marshal.SizeOf(typeof(byte)) * ByteStrm.Length);<br />
System.Runtime.InteropServices.Marshal.Copy(ByteStrm, 0, FntPtr, ByteStrm.Length);<br />
FntNc.AddMemoryFont(FntPtr, ByteStrm.Length);<br />
Int32 pcFonts;<br />
pcFonts = 1;<br />
AddFontMemResourceEx(FntPtr, ByteStrm.Length, 0, ref pcFonts);<br />
System.Runtime.InteropServices.Marshal.FreeHGlobal(FntPtr);<br />
}<br />
return FntNc;<br />
}<br />
}
and using this code on button click:
string[] fontNames = {"IDAutomationXC39M.ttf"};<br />
PrivateFonts privateFonts = new PrivateFonts();<br />
System.Drawing.Text.PrivateFontCollection FntNc = privateFonts.GetFont(fontNames);<br />
labelBarcode.Font = new Font(FntNc.Families[0], 12);
But it shows error in Program.cs the error is
System.ArgumentException was unhandled
Message="Parameter is not valid."
Source="System.Drawing"
StackTrace:
at System.Drawing.FontFamily.GetName(Int32 language)
at System.Drawing.FontFamily.get_Name()
at System.Windows.Forms.Internal.WindowsFont.FromFont(Font font, WindowsFontQuality fontQuality)
at System.Windows.Forms.Internal.WindowsGraphicsCacheManager.GetWindowsFont(Font font, WindowsFontQuality fontQuality)
at System.Windows.Forms.TextRenderer.DrawText(IDeviceContext dc, String text, Font font, Rectangle bounds, Color foreColor, TextFormatFlags flags)
at System.Windows.Forms.Label.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Label.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at BarcodeLabelGenerator.Program.Main() in E:\DEMO VERSION\BarcodeLabelGenerator\BarcodeLabelGenerator\Program.cs:line 18
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
|
|
|
|
|
i want to show a mdi child form from another mdi child form....i wrote the code like this
private void btnEdit_Click(object sender, EventArgs e)
{
if (Mdi.adminFormIsup == true)
this.MdiParent.ActiveMdiChild.Close();
if (!Mdi.adminFormIsup)
{
MDIDiary.Update up = new Update(Uid);
up.MaximizeBox = false;
up.MinimizeBox = false;
up.ControlBox = false;
up.Size = new Size(1032, 800);
up.StartPosition = FormStartPosition.CenterParent;
up.Location = new Point(110, 110);
up.MdiParent = this.MdiParent;
up.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
up.Show();
Mdi.adminFormIsup = true;
}
}it is working but it is not showing the mdi parent FormBorder and its toolstripmenuitem...please someone help
|
|
|
|
|
Neetu Maheshwari,
Where do you create the "toolstripmenuitem" ?
Regards,
Gareth.
|
|
|
|
|
gareth111 wrote: Where do you create the "toolstripmenuitem" ?
what r u saying....i have created "toolstripmenuitem" in mdi parent form...but i want to display a mdi child form from another mdi child form.....it is working but not showing the mdi parent form border and its toolstripmenuitem...so please help
|
|
|
|
|
I am getting these two errors:
Error 2 error LNK2028: unresolved token (0A00007F) "extern "C" long __stdcall RegEnumKeyExW(struct HKEY__ *,unsigned long,wchar_t *,unsigned long *,unsigned long *,wchar_t *,unsigned long *,struct _FILETIME *)" (?RegEnumKeyExW@@$$J232YGJPAUHKEY__@@KPA_WPAK212PAU_FILETIME@@@Z) referenced in function "public: void __clrcall BuildPatch::findRegPatch(void)" (?findRegPatch@BuildPatch@@$$FQAMXXZ) FormSearchFile.obj FormSearchFile
Error 6 error LNK2019: unresolved external symbol "extern "C" long __stdcall RegQueryValueExW(struct HKEY__ *,wchar_t const *,unsigned long *,unsigned long *,unsigned char *,unsigned long *)" (?RegQueryValueExW@@$$J224YGJPAUHKEY__@@PB_WPAK2PAE2@Z) referenced in function "public: void __clrcall BuildPatch::checkRegValues(struct HKEY__ *,wchar_t * const,wchar_t * const)" (?checkRegValues@BuildPatch@@$$FQAMXPAUHKEY__@@QA_W1@Z) FormSearchFile.obj FormSearchFile
Do I have to link some library files to the linker for the code to run??
How do I know which .lib files??
Som
|
|
|
|
|
First issue you have is that this is the C# forum, and C# does not use a linker. Were you looking for the C++ forum, or have you spammed the entire site ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
looks like I have posted in the wrong forum..
I was lokking for C++ forums..
Anyways, I will post it there..
If anybody knows the answer, it would be appreciated..
Som
|
|
|
|
|
MSDN is the place to search to find out what libs you need for specific C API calls. They tell you at the bottom what header you need, and what lib.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
Hi,
Kindly let me know that, is there any Date Difference method in c#?
or
will I have to use subtract?
Thank you in advance
(Riaz)
|
|
|
|
|
u can just subtract the dates
Rocky
Success is a ladder which you can't climb with your hands in your pockets.
|
|
|
|
|
This[^] might help you in future. Or a good book.
Subtracting one DateTime from another returns a TimeSpan object.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Been really plugging your article, haven't you?
Just kidding, of course.
Cheers,
Vikram.
Zeppelin's law: In any Soapbox discussion involving Stan Shannon, the probability of the term "leftist" or "Marxist" appearing approaches 1 monotonically.
Harris' addendum: I think you meant "monotonously".
Martin's second addendum: Jeffersonian... I think that should at least get a mention.
|
|
|
|
|