-2

Im developing a simple winform application which i would like to deploy to a mix of pcs - some x64 and some x86.

The application searches the harddrive for files containing text the user enters, and uses a backgroundworker to to the actual search so as not to lock the UI.

While still in visual studio, when i change the architecture of the winform project to 'Any CPU' or 'x64' and use F5 to load the application and enter a search term, i get the following error:

enter image description here

I'm targeting .NET framework 3.5

The application is fine and runs with no error when i Change it back to x86. I would like all users to be able to use the application and would appreciate some help in solving this.

thanks

EDIT 3

Another problem i have discovered is the application opens but returns no data when published or even from the debug folder after building ! Its just a winform with a datagridview and textbox on it. Any ideas?

Nick
  • 3,454
  • 6
  • 33
  • 56
  • 1
    Are you using any unmanaged DLLs? – Matthew Watson Jun 01 '18 at 10:26
  • @MatthewWatson i added an external DLL that does the search. is that what you mean by unmanaged? cheers – Nick Jun 01 '18 at 10:32
  • 3
    @Nick Some .DLLs only support certain architectures. If it runs x86, but fails on x64 and "Any CPU" then perhaps your library doesn't support x64. For the record, on windows 7 x64 machine, "Any CPU" defaults to 64 bit CLR. – Lucax Jun 01 '18 at 10:35
  • dependencies are compatible ? – Amit Jun 01 '18 at 10:36
  • @Lucax Changing the architecture on the second project does not have any effect. Its only the Winform project that has. The second project compiles to a DLL and is not a dll added using references > add reference. thx – Nick Jun 01 '18 at 10:38
  • You'll first have to learn how to debug this exception, then it becomes easy. Covered pretty well in [this Q+A](https://stackoverflow.com/questions/20452431/debugging-targetinvocationexception). – Hans Passant Jun 01 '18 at 10:41
  • @Nick Oh, I was under the impression it was a third party tool. For the record, 64 bit machines can run 32 bit programs. So in reality you could just build it x86 and it would work on 32 bit and 64 bit machines. – Lucax Jun 01 '18 at 10:43
  • You have a null reference exception. Check this https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it – Cleptus Jun 01 '18 at 10:44
  • If there was actually an error with Architecture then you might get BadImageFormat error, This is something else, Is it possible to paste the full exception data here? – Dharani Kumar Jun 01 '18 at 12:44

1 Answers1

2

Issue is probably with some DLL that you've added to your project. Some libraries fail on x64 or AnyCPU. I've had such issue last year.

Regarding:

I would like all users to be able to use the application and would appreciate some help in solving this.

If you compile it to x86, users should be able to use it on 64-bit machines without issue.

Caldazar
  • 2,801
  • 13
  • 21