Forums

.NET 4.0 support | -ref:System.Numerics.dll?

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

.NET 4.0 support | -ref:System.Numerics.dll?

Postby carlosqt » Mon Mar 28, 2011 7:20 am

Hi there,

Does Cobra targets only the .NET Framework 2.0, 3.0 and 3.5? is there any switch on the compiler command line to switch to use .NET 4.0?

When trying to reference a .dll assembly that is only available for the .NET Framework 4.0 i get the following error:

C:\Cobra\Cobra-0.8.0-post\bin>cobra test.cobra -ref:System.Numerics.dll

error: COBRA INTERNAL ERROR / BadImageFormatException / Could not load file or a
ssembly 'file:///C:\Cobra\Cobra-0.8.0-post\bin\System.Numerics.dll' or one of it
s dependencies. This assembly is built by a runtime newer than the currently loa
ded runtime and cannot be loaded.
Compilation failed - 1 error, 0 warnings
Not running due to errors above.

Thanks for the info.
carlosqt
 
Posts: 17
Location: Belgium

Re: .NET 4.0 support | -ref:System.Numerics.dll?

Postby RIGHT_THEN » Mon Mar 28, 2011 8:07 am

Hello Carlosqt

There are plans to bring up a .net 4.o compatible CobraCompiler
but certain things can still be done to overcome this issue

1) on commmand line you can specify which C# compiler to use to compile
your code -native-compiler[:file-system-path] default is auto
or
-sharp-compiler
like -native-compiler:"C:\Windows\Microsoft.NET\Framework\csc.exe"

2) while building Cobra in your cobra-workspace\source from install-from-workspace.bat
you can tweek install-from-workspace.cobra to use -kif:yes options
whereever it is calling compiler to compile. that way you would have
cobra source as c# files. you can then compile these c# files with C#4.0
compiler. so the resultant assembly/compiler will automatically be .net4.0
compatible.
3) you can go to
http://cobrapluginsd.codeplex.com/releases/
and download
CobraAsCsharp_4. In that you would find a .net 4 compatible compiler
which is gotten by the same process mentioned above. but it is old by
a couple of releases. but you would get the idea.

4) take cobra.exe and cobra.lang.dll use ILDASM of .net 4.0 and
pass it a a command line like this
ILDASM where_Ever_Cobra.exe_IsLocated\Cobra.exe /out=where_Ever_U_Want_ILToBe_Produced\Cobra.il
you will see a Cobra.il file produced now in that file after opening it in any Editor/notepad

write
// Metadata version: v4.0.30319
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly extern System
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}


instead of whatever you find instead of above written it would be
most probably v2.something and .ver 2:something

now use ILASM and pass it a command prompt line like this
ILASM pathofCobra.il\Cobra.il /EXE /out=cobra.exe
you will have a .net 4.0 compatible Cobra.exe
do the same for Cobra.Lang.dll

i just tested this way i am not sure if it would create problems in future
only problem i can think with this way is that if certain methods used
earlier which might not be in the new version might be troublesome
but you can try

Thanking_You
RIGHT_THEN
Last edited by RIGHT_THEN on Wed May 11, 2011 11:27 am, edited 2 times in total.
RIGHT_THEN
 
Posts: 99

Re: .NET 4.0 support | -ref:System.Numerics.dll?

Postby carlosqt » Mon Mar 28, 2011 9:56 am

Hi RIGHT_THEN,

Perfect, thanks for the replay.
I will try those options and see how it works.

Carlos
carlosqt
 
Posts: 17
Location: Belgium


Return to Discussion

Who is online

Users browsing this forum: No registered users and 33 guests