473,407 Members | 2,326 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,407 software developers and data experts.

C# and ILASM

yoz
Hi,

I am unsure where to post this. I have an MSIL dll.

----

..assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 )
.ver 1:0:5000:0
}

..namespace Test
{
.class public obj1 extends [mscorlib]System.Object
{
.method public hidebysig specialname rtspecialname instance void .ctor()
cil managed
{
.maxstack 1
ldarg.0
call instance void [mscorlib]System.Object::.ctor()
ret
}
}
}

---

that I compile with ilasm.exe

When I try to reference it in C# I get

"A reference to 'Test.dll' could not be loaded. This is not a valid assembly
or COM Component. Only assemblies with extension 'dll' and COM Components
can be referenced. Pleae make sure the file is accessible, and that it is a
valid assembly or COM Component".

The line to compile the module is
C:\WINNT\Microsoft.NET\Framework\v1.1.4322\ilasm.e xe obj1.msil /dll
/res:obj1.rct /output:Test.dll

the obj1.rct file is join to the mail. If you can't read it just create a
resource file in C# and add the version.

NB:

Another test was to try to load it via the System.Reflection.Assembly

System.Reflection.Assembly a = System.Reflection.Assembly.Load("obj1.dll");

this throws an exception with "File or assembly name
C:\Files\msil\test\obj1.dll, or one of its dependencies, was not found."

Thanks in advance
Yoz
Nov 15 '05 #1
2 6518
Yoz,

Your DLL lacks an assembly manifest (it's just a module), that's why
you can't reference it. Add something like

..assembly MyAsm
{
.ver 1:2:3:4
}

to your code.

Another test was to try to load it via the System.Reflection.Assembly

System.Reflection.Assembly a = System.Reflection.Assembly.Load("obj1.dll");

this throws an exception with "File or assembly name
C:\Files\msil\test\obj1.dll, or one of its dependencies, was not found."


Assembly.Load takes an assembly name, not a file path. To load an
assembly from a file path you use Assembly.LoadFrom.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #2
yoz
Thanks a lot.

Sorry, I am just a begginer :-)
"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:e8**************@tk2msftngp13.phx.gbl...
Yoz,

Your DLL lacks an assembly manifest (it's just a module), that's why
you can't reference it. Add something like

.assembly MyAsm
{
.ver 1:2:3:4
}

to your code.

Another test was to try to load it via the System.Reflection.Assembly

System.Reflection.Assembly a = System.Reflection.Assembly.Load("obj1.dll");
this throws an exception with "File or assembly name
C:\Files\msil\test\obj1.dll, or one of its dependencies, was not found."


Assembly.Load takes an assembly name, not a file path. To load an
assembly from a file path you use Assembly.LoadFrom.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.

Nov 15 '05 #3

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

Similar topics

1
by: Bob | last post by:
I'm taking a first look at MSIL and downloaded a sample project. In the file I see this message: * Build with "ilasm /EXE mandelbrot.il" on .Net RTM I can find ilasm nowhere, not on my hard...
5
by: Wiktor Zychla | last post by:
Hello, are there any good references to .NET history? I would like to read some more about the development of the ILasm language and the C# language. were they developed separately? is it true...
4
by: Wiktor Zychla | last post by:
Hello, for some reason I need to use attributes in ILAsm code and read these attributes in C# code. My problem is with the attribute declaration inside ILAsm code. I know that I define any...
4
by: Ioannis Vranos | last post by:
I have some thoughts lately, to get on ILASM. However may someone tell me whether the introduction of generics etc will have as a result additions or changes to the .NET assembly language? ...
8
by: suresh_C# | last post by:
Dear All, What is difference between Portable Executable (PE) file and a Assembly? Thanks, Mahesh
5
by: gpsmobiler | last post by:
Hi, I found through a lot of exhausting searching, that the following C# code will cause the IL code below: const byte ICON_MONO12BY12 =0; ....... IL-file.... .field literal private...
2
by: masoud moosavi | last post by:
hello, please give me the syntax of the ilasm language programmin,or write a simple program , thanks a lot
1
by: ajk | last post by:
Hi When doing a .NET compiler what are the benefits of generating ILAsm directly compared to generating another higher level language like C# first and then using the C# compiler? ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.