Problen with MissingManifestResourceException

G

Guest

Hallo,

I have a problem with a MissingManifestResourceException. I'm trying by days
without finding any solution.
Shortly the context:

I have a .Net application (APPL_1), which does the following:
- purpose: generate resources file in Online dialog for a VS 2005 project
- gets as parameter the base-directory of another Application. (Here: a VS
2005 Project APPL_2.exe)
- creates localized resource objects (in dialog with user) and stores them
in .resources files.
example: APPL_2.resources, APPL_2.de.resources,
APPL_2.de-DE.resources , ...
- creates the satellite assemblies using AL-utility (via Process) using the
created resources files
APPL_2.dll (for de), APPL_2.dll (for de-DE) and stores
them as
APPL_2\bin\debug\de\APPL_2.dll
APPL_2\bin\debug\de-DE\APPL_2.dll
- copies the neutral resources file: to directory
APPL_2\Resources\APPL_2.resources to be embedded in the APPL_2.exe

Working with VS 2005 (Project APPL_2)
- The APPL_2\Resources\APPL_2.resources is added to the project
- the property Embedded Resource is set
- The namespace of all .cs files is the same (company.Net.APPL_2)
- the default namespace in properties of project is the same
(company.Net.APPL_2)
- after building the project, the resource file the obj\debug contains
company.Net.APPL_2.APPL_2.resources (as exspected)

now I exspect, that this resources file after building is embedded in the
main assembly representing the neutral culture.

Running:
- CurrentUICulture is not chganged (de-DE)
- A ResourceManager is created : rm = new ResourceManager("APPL_2",
Assembly.LoadFrom("APPL_2.exe"));
- the access: object x = rm.GetObject("anykey")

- if the resource with that key is available in any satellite, it is
accessed without errors
- if not, I get the MissingManifestResourceException, regardless of the
existence of that key in the neutral resources.

I don't find a way, to get a successful access on the neutral resources.

- if rm is created with : .... Assembly.LoadFrom("APPL_2.exe"), no success
- if rm is created with : .... Assembly.GetExecutingAssembly), no success

I appreciate any help, thankyou
Michael
 
L

Linda Liu [MSFT]

Hi Michael,

I am sorry that I may not understand your scenario exactly. Based on my
understanding, you have an application called APPL_1 which is used to
generate resources file for another application APPL_2. The problem is that
you couldn't access the data correctly in the neutral resources in the
APPL_2. If I'm off base, please feel free to let me know.

For application internationalization, we usually create culture-specific
resource files and then bundle them into a satellite assembly per culture.
The satellite assembly should have the name of
'projectnamespace.projectname.resources.dll'.

As for the culture-neutral resource, it should be bundled into the main
assembly and we usually do this when compiling the project. For example,
VS05 uses the following command to compile the project with the /resource
switch:

C:\WINNT\Microsoft.NET\Framework\v2.0.50727\Csc.exe /noconfig
/nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE
/reference:C:\WINNT\Microsoft.NET\Framework\v2.0.50727\System.Data.dll
/reference:C:\WINNT\Microsoft.NET\Framework\v2.0.50727\System.Deployment.dll
/reference:C:\WINNT\Microsoft.NET\Framework\v2.0.50727\System.dll
/reference:C:\WINNT\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll
/reference:C:\WINNT\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.
dll /reference:C:\WINNT\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll
/debug+ /debug:full /optimize- /out:blush:bj\Debug\ResourceTest.exe
/resource:blush:bj\Debug\ResourceTest.Form1.resources
/resource:blush:bj\Debug\ResourceTest.Properties.Resources.resources
/target:winexe Form1.cs Form1.Designer.cs Program.cs
Properties\AssemblyInfo.cs Properties\Resources.Designer.cs
Properties\Settings.Designer.cs

It seems that after building the project APPL_2, the culture-neutral
resource file is not bundled into the main assembly in your scenario. In
addition, we couldn't use the Al.exe command to bundle the culture-neutral
resource into the main assembly. When we do this, the previous meta data in
the main assembly will be flushed.

If the problem is still not resolved, could you please send me a sample
project that could just reproduce the problem? To get my actual email
address, remove 'online' from my displayed email-address.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
L

Linda Liu [MSFT]

Hi Michael,

Thank you for your detailed explanation. I understand your problem now.

Even if you place the culture-neutral resource under the Properties folder
of the APP_2 project, I don't think the resource will be bundled into the
main assembly of the APPL_2 when you build it.

FYI, you may use the .NET utility 'IL DASM' to check if a resource is
bundled properly into an assembly. To access this utility, type the command
'ildasm' in the Visual Studio 2005 command prompt. Open the main assembly
of the APPL_2 in the tool 'IL DASM' and double click the 'MANIFEST' node.
You should be able to see a .mresource token for the culture-neutral
resource in the 'MANIFEST' window, similar to the following, if the
resource is successfully bundled.

.mresource public APPL_2.resources
{
// Offset: 0x00000000 Length: 0x000000B4
}

To embed a resource into an assembly properly, I suggest that you write the
the compilation command by yourself and specify the culture-neutral
resource with the 'resource' switch in the compilation command to build the
APPL_2 project.

The following is the compilation command samples.

VB.NET project compilation command sample:

D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Vbc.exe /noconfig
/imports:Microsoft.VisualBasic,System,System.Collections,System.Collections.
Generic,System.Data,System.Drawing,System.Diagnostics,System.Windows.Forms
/nowarn:42016,41999,42017,42018,42019,42032,42036,42020,42021,42022
/rootnamespace:vbproject /doc:blush:bj\Debug\vbproject.xml
/define:"CONFIG=\"Debug\",DEBUG=-1,TRACE=-1,_MyType=\"WindowsForms\",PLATFOR
M=\"AnyCPU\""
/reference:D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll,D:\
WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Deployment.dll,D:\WINDOWS\
Microsoft.NET\Framework\v2.0.50727\System.dll,D:\WINDOWS\Microsoft.NET\Frame
work\v2.0.50727\System.Drawing.dll,D:\WINDOWS\Microsoft.NET\Framework\v2.0.5
0727\System.Windows.Forms.dll,D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\
System.Xml.dll /main:vbproject.My.MyApplication /debug+ /debug:full
/out:blush:bj\Debug\vbproject.exe
/resource:blush:bj\Debug\vbproject.Resources.resources /target:winexe Form1.vb
Form1.Designer.vb "My Project\AssemblyInfo.vb" "My
Project\Application.Designer.vb" "My Project\Resources.Designer.vb" "My
Project\Settings.Designer.vb"

C# project compilation command sample.

D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Csc.exe /noconfig
/nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE
/reference:D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll
/reference:D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Deployment.d
ll /reference:D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll
/reference:D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll
/reference:D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Form
s.dll
/reference:D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll
/debug+ /debug:full /optimize- /out:blush:bj\Debug\TopMostWithoutFocusForm.exe
/resource:blush:bj\Debug\TopMostWithoutFocusForm.Form1.resources
/resource:blush:bj\Debug\TopMostWithoutFocusForm.Form2.resources
/resource:blush:bj\Debug\TopMostWithoutFocusForm.Properties.Resources.resources
/target:winexe Form1.cs Form1.Designer.cs Form2.cs Form2.Designer.cs
Program.cs Properties\AssemblyInfo.cs Properties\Resources.Designer.cs
Properties\Settings.Designer.cs

Hope this helps.
If you have any question, please feel free to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support
 
L

Linda Liu [MSFT]

Hi Michael,

Thank you for your prompt response.

Firstly, I notice that the manifest of the Ebhab.dll is same as that of the
RESMANAGER.EXE, which shouldn't be the same. Did you make a mistake?

Secondly, do you mean that the culture-neutral resource is
Ebhab.Net.Windows.Forms.Resources.Ebhab.resources? From the manifest you
provided, it seems that this resource is bundled in the Ebhab.dll assembly.
So you should be able to access this resource within the Ebhab.dll assembly
using the following statement:

ResourceManager rm = new
ResourceManager(typeof(Ebhab.Net.Windows.Forms.Resources.Ebhab));
object obj = rm.GetObject(anykey);

Or you may also access this resource in the RESMANAGER.exe using the
following statement:

Assembly ass = Assembly.LoadFile(Application.StartupPath + "\\Ebhab.dll");
ResourceManager rm = new ResourceManager(anykey,ass);

Hope this helps.


Sincerely,
Linda Liu
Microsoft Online Community Support
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top