I have a project with two namespaces, and all I want to do is load a cursor resource in one of them. Sounds simple doesn't it
The cursor has it's Build Action property set to Embedded Resource.
I use the following code to load it:
Cursor = new Cursor(GetType(), "Rectangle.cur");
This works fine in one namespace, but fails in the other. I receive an unhandled exception of type 'System.NullReferenceException'. Additional information: Object reference not set to an instance of an object.
Can someone tell me how to overcome this error please
Thanks!

Cursor problem
Bava Mani
I tried what you said and was successful! Thanks.
Do you have any idea about how I would set about transferring the resource into the other namespace
Craig Reder
Try this:
using( Stream resStream = asm .GetManifestResourceStream( "MyNameSpace.Rectangle.cur" ) )
{
Cursor cursor = new Cursor( resStream );
}
You can print all your resource names to the console for example to lookup if the resource exists:
Assembly asm = Assembly.GetExecutingAssembly();
Console.WriteLine( "Manifest resources for {0}", asm.FullName );
foreach( String resourceName in asm.GetManifestResourceNames() )
{
Console.WriteLine( "\t{0}", resourceName );
}
Sandor Heese
The constructor you are using, takes the namespace of the passed in type. So you should pass in a type of the namespace that contains the cursor.
Sven
Aiven
Tried this:
Cursor= new Cursor(GetType(), "MyNamespaceName.Rectangle.cur");
("MyNamespaceName" is the name the namespace containing the embedded resource cursor.)
I received the same error :(
mruniqueid
The documentation about this ctor: Cursor Constructor (Type, String).
HeyTad
I'm glad it worked!