|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Embedding resource files in CLASS LIBRARYreasons. I'd like to be able to just edit the source files and rebuild the library to update the resources (ie no cumbersome multi-step procedure). I found this page that shows how to do exactly what I want, but it is for executables: http://www.devx.com/dotnet/Article/10831/1954?pf=true According to those instructions I added the files in the solution explorer and set the build action to "embedded resource". However, I failed to access the resources (which I realized the page also says, when checked again). See code below. I can't see any resources in the DLL when I examine it with ildasm. StreamReader sr = new StreamReader(Assembly.GetEntryAssembly().GetManifestResourceStream(name)); Fails with "Object reference is not set to an instance of an object" Is there a way I can do this in a class library? Thanks for any tips! Marcus Marcus,
>StreamReader sr = new GetEntryAssembly() returns the assembly that started the appdomain. In>StreamReader(Assembly.GetEntryAssembly().GetManifestResourceStream(name)); >Fails with "Object reference is not set to an instance of an object" > >Is there a way I can do this in a class library? a class library you probably want GetExecutingAssembly instead. Mattias -- Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup. Yep, now it's working. Thanks!!!
Tack så mycket. ;) Marcus Show quoteHide quote "Mattias Sjögren" <mattias.dont.want.spam@mvps.org> wrote in message news:euQsMInDFHA.4020@TK2MSFTNGP14.phx.gbl... > Marcus, > >>StreamReader sr = new >>StreamReader(Assembly.GetEntryAssembly().GetManifestResourceStream(name)); >>Fails with "Object reference is not set to an instance of an object" >> >>Is there a way I can do this in a class library? > > GetEntryAssembly() returns the assembly that started the appdomain. In > a class library you probably want GetExecutingAssembly instead. > > > > Mattias > > -- > Mattias Sjögren [MVP] mattias @ mvps.org > http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com > Please reply only to the newsgroup. |
|||||||||||||||||||||||