473,663 Members | 2,738 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can not read resource from dynamicaly generated resource dll

Hi all,

I created resource dll dynamicaly using this code

AppDomain curDom = AppDomain.Curre ntDomain;
AssemblyName myAssemblyName = new AssemblyName();
imagesAssemblyN ame.Name = "Images";
AssemblyBuilder myAssemblyBuild er =
curDom.DefineDy namicAssembly(m yAssemblyName,
AssemblyBuilder Access.Save);
ModuleBuilder myModuleBuilder =
myAssemblyBuild er.DefineDynami cModule("Images .dll",
"Images.dll",tr ue);
IResourceWriter rsxw = myModuleBuilder .DefineResource ("Images",
"Descriptio n");
Image image = Image.FromFile( "myImage.gi f");
rsxw.AddResourc e("pic",image );
myAssemblyBuild er .Save("Images.d ll");

Then tried to get that image from another application.
ResourceManager res = new ResourceManager ("Images",
Assembly.LoadFi le(Directory.Ge tCurrentDirecto ry() + "\\" +
"Images.dll "));
Image image = (Bitmap)(res.Ge tObject("pic")) ;

But got exception
"Could not find any resources appropriate for the specified culture
(or the neutral culture) in the given assembly. Make sure
"Images.resourc es" was correctly embedded or linked into assembly
"Images"

In ILDASM can see that i have correct resource name
..mresource public Images
{
}
but still can not get resource

I would greatly appreciated any tips on what is going on in there.

Thank you

Roman
Nov 16 '05 #1
1 2552
The problem is that the ResourceManager can only read resources which are in
the binary .resources format, and you need to include ".resources " in name
parameter in DefineResource. So you need to change the call like this:
instead of:
IResourceWriter rsxw = myModuleBuilder .DefineResource ("Images","Desc ription");
use:
IResourceWriter rsxw = myModuleBuilder .DefineResource ("Images.resour ces",
"descriptio n");
Hope this solution works for you. Marin

"Roman Muntyanu" wrote:
Hi all,

I created resource dll dynamicaly using this code

AppDomain curDom = AppDomain.Curre ntDomain;
AssemblyName myAssemblyName = new AssemblyName();
imagesAssemblyN ame.Name = "Images";
AssemblyBuilder myAssemblyBuild er =
curDom.DefineDy namicAssembly(m yAssemblyName,
AssemblyBuilder Access.Save);
ModuleBuilder myModuleBuilder =
myAssemblyBuild er.DefineDynami cModule("Images .dll",
"Images.dll",tr ue);
IResourceWriter rsxw = myModuleBuilder .DefineResource ("Images",
"Descriptio n");
Image image = Image.FromFile( "myImage.gi f");
rsxw.AddResourc e("pic",image );
myAssemblyBuild er .Save("Images.d ll");

Then tried to get that image from another application.
ResourceManager res = new ResourceManager ("Images",
Assembly.LoadFi le(Directory.Ge tCurrentDirecto ry() + "\\" +
"Images.dll "));
Image image = (Bitmap)(res.Ge tObject("pic")) ;

But got exception
"Could not find any resources appropriate for the specified culture
(or the neutral culture) in the given assembly. Make sure
"Images.resourc es" was correctly embedded or linked into assembly
"Images"

In ILDASM can see that i have correct resource name
..mresource public Images
{
}
but still can not get resource

I would greatly appreciated any tips on what is going on in there.

Thank you

Roman

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5836
by: Gabriel Lozano-Morán | last post by:
First of all sorry for the cross-posting but I am not sure wether this belongs under internationalization or just general. Environment: Visual Studio .NET 2003 Problem: Newly added and renamed resource files are not automatically linked to the object they belong by the IDE
1
4146
by: Scott Smith | last post by:
Several attributes and interface methods I'm using refer to resources (such as strings or icons) by a numeric ID. This was the only way to refer to resources in unmanaged code (C++, for example), but I'm writing in C# now, and it seems that resources are named with string identifiers. Visual Studio doesn't seem to like resource names such as "100", so I'm wondering how this could work. Is it absolutely necessary for me to have a...
3
1685
by: minigitoo | last post by:
Hi I try to get dynamicaly all requests made to DB2 I process like this: 1) I stop then start my instance of database in the db2 control center 2) I use : db2 update monitor switches using statement on 3) then: db2 get snapshot for dynamic sql on <MyDatabase> I manage to get logs between instant t1 and t2, but i would like to see dynamicaly request which come to db2. I mean i would like to see in a
2
3809
by: HaukiDog | last post by:
Hi, I am trying to set up my C# web project to be compiled by NANT. Everything compiles and works fine within the IDE. I have a created a NANT build file which has a simple project tag, like this: <?xml version="1.0" ?> <project name="MyProject" default="build" basedir="."> <description>The Hello World of build files.</description> <property name="debug" value="true"/>
0
3424
by: SHC | last post by:
Hi all, I saw the following 2 files used in the OpenGL and DirectX 9 programming: 1) resource.h //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. // Used by dx9_indexed_geometry.rc // #define IDC_MYICON 2 #define IDD_DIRECTX_DIALOG 102 #define IDD_ABOUTBOX 103
1
3355
by: urban.john | last post by:
Here are my steps: create resource files from resx files: <echo message="CREATING RESOURCE FILES FROM RESGEN EN" /> <resgen todir="product\resources_en" verbose="true"> <resources> <include name="${AppName}\**.en.resx" /> <include name="${AppName}\Global.asax.resx" /> </resources>
9
2832
by: Alf P. Steinbach | last post by:
<what to design a C++ solution for> A Windows API /resource/ is data embedded in the executable, accessed via API functions. A resource is completely identified by the quadruple (id, type, language, file), where (1) id is what, for want of a better name, I'll call a /kludgeon/, (2) type is also a kludgeon, (3) language is a small integer identifying a concrete national language or one of a set of pseudo-languages such as the Windows...
1
1404
by: Jason Richmeier | last post by:
In a project I am working on, it sounds like resource files are what I need (to group things like error message strings). If I put a resource file in a project, everything will work fine. However, what I would like to be able to do is to put the resource files in a code library of some sort (I am not sure if I am saying that correctly). From reading some of the documentation (and some painful trial and error), I have figured out how to...
7
2102
by: craig | last post by:
....quick question for anyone who might have some experience with .net resource files in VS 2003. I have an application that is not localized, but I would still like to be able to place all of the images that are used for icons across all of the forms in all of the assemblies in a single resource file so that swaping out an image in the resource file affects all localtions that it appears in the app. Is there a way to create a single...
0
8436
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8345
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8858
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7371
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4182
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4349
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2763
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2000
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1757
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.