Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Compiling for 'AnyCPU' through errors
Message
From
07/04/2011 03:36:47
 
 
To
06/04/2011 17:43:14
General information
Forum:
ASP.NET
Category:
Forms
Miscellaneous
Thread ID:
01506035
Message ID:
01506335
Views:
112
>The ActiveX component is 32bit and yes there is a 64bit version
>
>but didn't you say earlier the app doesn't realy run as 64bit, That the AnyCPU alows it to run on a 64bit machine but in 32bit mode.

No. To summarise: When you compile a .NET application it is compiled to IL (Intermediate Language) code which is platform agnostic. If you set the Target platform to x86 the *JIT* compiler will compile to 32 bit machine code and, if running on a 64-bit machine, this will be executed using the emulator. If you set the target platform to 'Any CPU' then the JIT compiler will compile to 64 bit on a 64 bit machine (32 bit on a 32-bit).

As I understand it (but I confess to being a bit hazy on this) 64-bit code cannot load 32-bit Windows DLLs (and vice versa) so if you target 'Any CPU' , run on a 64-bit machine and attempt to use a 32-bit ActiveX control you will have problems.

>in that case it realy shouldn't matter - right?
>
>
>
>>Is the ActiveX component 32bit? I'm a bit out of my depth here but I'd imagine that trying to run 32bit unmanaged code from a 64-bit net app is going to be problematic :-}
>>Is there a 64bit version of the ActiveX available ?
>>
>>>I have been looking at the build/startup log when starting my app on the dev machine.
>>>
>>>I noticed that right before the error it is loading and unloading a PDF viewer my app uses
>>>'DMS DataEntry.exe': Loaded 'D:\...\bin\Debug\PDFXCviewAx.dll', Binary was not built with debug information.
>>>'DMS DataEntry.exe': Unloaded 'D:\...\bin\Debug\PDFXCviewAx.dll'
>>>A first chance exception of type 'System.BadImageFormatException' occurred in System.Windows.Forms.dll
>>>
>>>this is the activeX pdf viewer from Tracker Software (http://www.tracker-software.com/) i am using there. so i am thinking maybe that that viewer has something to do with my error.
>>>
>>>But 1st the entries before the error look normal
>>>and 2nd how would one go about having 2 activeX versions on a vb.net form - a 32-bit and a 64-bit version?
>>>
>>>
>>>
>>>
>>>>To be clear - did this occur when running the skeletal project I suggested. If not then try that. Is so try this:
Module Module1
>>>>    Sub Main()
>>>>        Console.WriteLine(IntPtr.Size.ToString())
>>>>        Try
>>>>            Dim em As System.Linq.ParallelExecutionMode = System.Linq.ParallelExecutionMode.Default
>>>>        Catch ex As Exception
>>>>            System.Diagnostics.Debugger.Break()
>>>>        End Try
>>>>        Console.ReadLine()
>>>>    End Sub
>>>>End Module
Console write should be '4' if running in a 32-bit environment, '8' for 64-bit. The catch may give you a bit more information on the exact nature of the problem if in the IDE (check for inner exceptions)
>>>>
>>>>FWIW I think the path you mention is normal for the framework DLL's - but if the exception occurs in the line that uses System.Linq I don't know there System.Windows.Forms.dll comes into it ?
>>>>Also, FWIW, I ran the above code on a 64-bit WIN7 machine in both 32 and 64 bit modes with no problem.
>>>>Where did you find any references to problems with System.Windows.Forms.dll on 64-bit ?
>>>>
>>>>
>>>>>Before I do that it occured to me that i am developing this on a win2003 64-bit machine. So instead of just building and then installing on another pc i run it right out of VS2010.
>>>>>
>>>>>There i get the following error running as AnyCPU:
>>>>>A first chance exception of type 'System.BadImageFormatException' occurred in System.Windows.Forms.dll
>>>>>'DMS DataEntry.exe': Loaded 'C:\Windows\System32\version.dll', Cannot find or open the PDB file
>>>>>An unhandled exception of type 'System.InvalidOperationException' occurred in DMS DataEntry.exe
>>>>>some research suggests that there is an issue with 64-bit version of System.Windows.Forms.dll. I looked where the file is comming from (in the properties) and it comes from "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Windows.Forms.dll" - notice the "x86" - but so do most of the other dlls listed in the references.
>>>>>
>>>>>I also tried to add an exeption routine to my app - ran into problems. But I think i start a seperate thread for that.
>>>>>
>>>>>Thanks.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>As per the namespace the ParallelExecutionMode enum *needs* System.Linq. The question was whether use of just that line also causes an exception on the XP/64 machine. See if this one-line project will run:
Module Module1
>>>>>>    Sub Main()
>>>>>>        Dim em As System.Linq.ParallelExecutionMode = System.Linq.ParallelExecutionMode.Default
>>>>>>    End Sub
>>>>>>End Module
Also, as mentioned earlier, look at catching unhandled exceptions in code - that will give you more information on the exception details.
>>>>>>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform