473,378 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

BadImageFormatException from mixed-mode multi-file assembly

I have mixed-mode multi-file assembly of several netmodules and a dll. All
are generated using c# compiler, vc++ compiler and vc++ linker from command
prompt. I can browse the content of the assembly from vs.net ide and roeder's
..net reflector, but when I run a c# console project that references to the
dll, it throws BadImageFormatException.

I'm guessing the error probably has to do with compiler/linker option bits
that are used to built the assembly.

link /LTCG /CLRIMAGETYPE:IJW /NOENTRY /DLL
/ASSEMBLYMODULE:Release/Shared.netmodule
/ASSEMBLYMODULE:Release\Native.netmodule
/ASSEMBLYMODULE:Release\Numerics.netmodule
/ASSEMBLYMODULE:Release\C5Collections.netmodule /OUT:Release\CommonLib.dll
Release\Common.dll ..\Src\version.res /LIBPATH:"C:\Program Files\Microsoft
Visual Studio 8\VC\" /LIBPATH:"../Lib/MKL"

Does anyone have any ideas of what is wrong?

-- Thanks Henry
Jun 27 '08 #1
4 2867
Commonly those errors occurs when you have different platform compiled
assemblies.

For example, you has compiled one assembly for x86 and other for AnyCPU.
When the AnyCPU calls the x86 gives the error.

"ignhenry" <ig******@nospam.nospamwrote in message
news:97**********************************@microsof t.com...
>I have mixed-mode multi-file assembly of several netmodules and a dll. All
are generated using c# compiler, vc++ compiler and vc++ linker from
command
prompt. I can browse the content of the assembly from vs.net ide and
roeder's
.net reflector, but when I run a c# console project that references to the
dll, it throws BadImageFormatException.

I'm guessing the error probably has to do with compiler/linker option bits
that are used to built the assembly.

link /LTCG /CLRIMAGETYPE:IJW /NOENTRY /DLL
/ASSEMBLYMODULE:Release/Shared.netmodule
/ASSEMBLYMODULE:Release\Native.netmodule
/ASSEMBLYMODULE:Release\Numerics.netmodule
/ASSEMBLYMODULE:Release\C5Collections.netmodule /OUT:Release\CommonLib.dll
Release\Common.dll ..\Src\version.res /LIBPATH:"C:\Program Files\Microsoft
Visual Studio 8\VC\" /LIBPATH:"../Lib/MKL"

Does anyone have any ideas of what is wrong?

-- Thanks Henry
--
Microsoft Visual C++ MVP
========================
Mi blog sobre programación: http://geeks.ms/blogs/rfog
Momentos Leves: http://momentosleves.blogspot.com/
Cosas mÃ*as: http://rfog.blogsome.com/
Libros, ciencia ficción y programación
========================================
El amor es ciego, pero el matrimonio le devuelve la vista.
-- Georg Lichtenberg. (1742-1799) Profesor de fÃ*sica y cientÃ*fico alemán.

Jun 27 '08 #2
Hi Henry,

Since most of linker options are the same as used in the link below, I did
not see anything wrong with it.
http://blogs.msdn.com/texblog/archiv...e-c-into-c-app
lications.aspx

Also, since the "Add Reference" in the VS IDE works and the .Net Reflector
works, I think the metadata and manifest of the assembly is correct.

Can you show me the detailed stack trace of this BadImageFormatException as
it throws at runtime? It is helpful if you can provide both the native and
managed stack traces. To get the native stack, you may have to turn on the
unmanaged debugging in the VS debugger->Project Property->Debug->Enable
unmanaged code debugging. Also, you have to setup the Microsoft symbol
server correct, so that the native addresses are resolved as function names
correctly.

Finally, do you have the detailed steps to help me reproduce this problem?
Once I can reproduce it locally, I can contact the C++/CLI team to
collaborate on it. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 27 '08 #3
Jeffrey,

I have created a .NET solution containing some projects and also steps to
reproduce the problem. I'm using my browser to access the newsgroup and I
don't see anywhere here I can attached a file. Is it possible to send the
solution to you?

--Thanks - Henry

""Jeffrey Tan[MSFT]"" wrote:
Hi Henry,

Since most of linker options are the same as used in the link below, I did
not see anything wrong with it.
http://blogs.msdn.com/texblog/archiv...e-c-into-c-app
lications.aspx

Also, since the "Add Reference" in the VS IDE works and the .Net Reflector
works, I think the metadata and manifest of the assembly is correct.

Can you show me the detailed stack trace of this BadImageFormatException as
it throws at runtime? It is helpful if you can provide both the native and
managed stack traces. To get the native stack, you may have to turn on the
unmanaged debugging in the VS debugger->Project Property->Debug->Enable
unmanaged code debugging. Also, you have to setup the Microsoft symbol
server correct, so that the native addresses are resolved as function names
correctly.

Finally, do you have the detailed steps to help me reproduce this problem?
Once I can reproduce it locally, I can contact the C++/CLI team to
collaborate on it. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 27 '08 #4
Hi Henry,

Thanks for your feedback.

Yes, only the Outlook Express can attach a sample project to the newsgroup,
IE can not. Anyway, please feel free to send your project with the detailed
reproduce steps to me at: je***@online.microsoft.com(remove "online.")

I prefer reproduce steps because it allows me to try it step by step and
validate if any step is invalid or may cause the problem.

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=========================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

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

Jun 27 '08 #5

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

Similar topics

3
by: Perttu Pulkkinen | last post by:
No questions, but just consider if this is useful to you:-) but of course feedback & corrections are welcome. function php_mixed_to_js_value($jsname, $mixed) { if(is_null($mixed)) { return "\n...
2
by: Paul A. Hoadley | last post by:
Hello, I am trying to convert a RELAX NG schema to DTD using Trang. I am currently trying to add some inline elements to the schema, such as <emph> for marking emphasised text. Here is an...
15
by: Bill Cohagan | last post by:
I'm trying to generate class definitions from an XSD that contains something like: <xs:complexType name="foo" mixed="true"> <xs:choice minOccurs = "0" maxOccurs="unbounded"> <xs:element name =...
0
by: samsonfr | last post by:
Hello, I have read KB 814472 and the article "How To: Remove Dependency on _vcclrit.h" (http://msdn2.microsoft.com/en-us/library/ms173267(en-us,vs.80).aspx) which confirmed that VS.NET 2005...
3
by: Installutil System.BadImageFormatExcepti | last post by:
I've tried to make a Windows Service using the 2005 C# and when I go to use Installutil it returns with an System.BadImageFormatException error while intializing the installation. I've even gone as...
1
by: cwjacklin | last post by:
I read this article on http://msdn.microsoft.com/msdnmag/issues/03/07/NET/ which describes how to invoke C win32 dll from C# But I am running into a weird situation. I have an existing C...
1
by: notis | last post by:
Hi all, I am trying to port an application developed with VS2003 to VS2005. The project builds successfuly but when I run it, it throws a BadImageFormatException in the following line of code in...
3
by: notis.stamos | last post by:
Hi all, I am trying to port an application developed with VS2003 to VS2005. The project builds successfuly but when I run it, it throws a BadImageFormatException in the following line of code in...
4
by: Glenn Palomar | last post by:
Hi, I have VB.net application that I recently migrated from VS2003 to VS2005. It works fine in Windows XP and 2K but NOT in XP64. I get an exception error that says...
1
by: andrew_nuss | last post by:
Hi, Lets say I have a MIXED tag in my XML DTD with content that is going to be rendered as HMTL, as well as a <boldand <italicstag. What about whitespace? Specifically, does the whitespace in...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.