I am trying to change my Platform target for a C# application from x86 to Any CPU. My application uses a _click method which runs a new thread which opens a viewer window using the following method to show the window:
public void Show(string url, int entityId, string sessionId, int projId, string docId)
{
base.Show();
try
{
this.DocViewer.InitComm(url, entityId, sessionId, projId, docId);
}
catch (Exception ex)
{
Logger.Error("Error opening viewer", ex);
throw;
}
}
When running on the x86 platform, the application runs without issue. I changed the platform to "Any CPU" and receive a "COMException was unhandled" error: "Class not regisered (Exception from HRESULT: 0X80040154 (REGDB_E_CLASSNOTREG))" highlighting:
base.Show();
I have researched the cause of this error and it seems to be due to registry redirection. Because I am using .NET 3.5, I have been unable to use many of the solutions that I have found including one from this thread on SO. I am unclear on how the information here could be helpful as many of the links to the code are in C++.
If anyone could provide me with insight I would greatly appreciate it.
This is an entirely normal mishap. Clearly you have a dependency on a COM server and they care a great deal about whether your program runs in 32-bit or 64-bit mode. COM servers are written in native code, usually C++, and a different flavor of native code is required in 64-bit mode.
You can only count on having a 64-bit version of such a COM server if it is part of Windows and not too old. But the vast majority of them are 3rd party products and only available as a 32-bit version. If it is your own then you'll have to build the x64 version of it, if it is a 3rd party then you'll have to use a telephone. We can't help you locate the number. If you need a hint then look through your project's assembly references and look at the Properties of the file, decent odds you'll see the vendor name in the Copyright notice.