coltsith

I'm getting a NotSupportedException when I try to create and assign a font object:


Code Snippet

public static readonly Font = new Font(FontFamily.GenericMonospace, 12, FontStyle.Regular);

Could someone tell me why Thanks!


Re: .NET Base Class Library Constructing Fonts and .NET 1.0? (NotSupportedException)

nobugz

Run Notepad.exe, Format + Font. Do you see "Courier New" in the list





Re: .NET Base Class Library Constructing Fonts and .NET 1.0? (NotSupportedException)

coltsith

Yes. I tried some more things, and even assigning null throws the NotSupportedException.

What I'm doing now is having the variable only static and assigning it in a setup helper method, not at compile time.




Re: .NET Base Class Library Constructing Fonts and .NET 1.0? (NotSupportedException)

Feng Chen - MSFT

Hi,

You said "What I'm doing now is having the variable only static and assigning it in a setup helper method, not at compile time".

Does it work correctly now, please

I can't repro this NotSupportedException.

To troubleshoot this issue, could you please post the stacktrace of the exception

And we really need the source code to reproduce the problem, so that we can investigate the issue in house. It is not necessary that you send out the complete source of your project. We just need a simplest sample to reproduce the problem. You can remove any confidential information or business logic from it.

Thanks!






Re: .NET Base Class Library Constructing Fonts and .NET 1.0? (NotSupportedException)

coltsith

Feng,

Yes it works correctly now, but I'm no longer using 1.0. What I had was:

Code Snippet


public static readonly Font font1;
public static readonly Font font2;
public static readonly Font font3;

public static void SetupFonts() {
font1 = ...;
font2 = ...;
font3 = ...;
}


And I called SetupFonts when the app started up. But like I said, I'm no longer using 1.0. Half of my code writing in 2.0 stopped working or had problems.