System.Runtime.InteropServices.COMException | vb.net - vb.net

I know this question has been answered many times but I have tried all previous suggested resolution.
1.) The target CPU is x86
2.) I have registered the ocx and dll files
The application is working fine on old machines (all OS) but not on new images.
Here is the log :
Framework Version: v4.0.30319 Description: The process was terminated
due to an unhandled exception. Exception Info:
System.Runtime.InteropServices.COMException at
System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(System.Guid
ByRef, System.Object, Int32, System.Guid ByRef) at
System.Windows.Forms.AxHost.CreateWithLicense(System.String,
System.Guid) at
System.Windows.Forms.AxHost.CreateInstanceCore(System.Guid) at
System.Windows.Forms.AxHost.CreateInstance() at
System.Windows.Forms.AxHost.GetOcxCreate() at
System.Windows.Forms.AxHost.TransitionUpTo(Int32) at
System.Windows.Forms.AxHost.CreateHandle() at
System.Windows.Forms.Control.CreateControl(Boolean) at
System.Windows.Forms.Control.CreateControl(Boolean) at
System.Windows.Forms.AxHost.EndInit() at
Restaurant.frmMain.InitializeComponent() at
Restaurant.frmMain..ctor()
Exception Info: System.InvalidOperationException at
Restaurant.My.MyProject+MyForms.Create__Instance__[System.__Canon,
mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089] at
Restaurant.frmMain.Main()
Here is how I am registering the files :
C:\Windows\Microsoft.NET\Framework\v2.0.50727\Caspol -q -machine -addgroup 1 -url file://C:/xyz/* FullTrust -name "V Drive"
regsvr32 c:\xyz\crystl32.ocx
regsvr32 c:\xyz\MSCOMCT2.OCX
regsvr32 c:\xyz\MSDATGRD.OCX
regsvr32 c:\xyz\cpeaut32.dll
regsvr32 c:\xyz\msstdfmt.dll
Crystal reports runtime engine for .NET 4 framework in installed on the system (both x86 and x64).

I had this issue once.
I ran Visual Studio as administrator.
Also make sure you know which setting your platform is for the build: AnyCPU, x86, x64
For you its x86 so try using AnyCPU!
Try debugging the issue
I read an article from Microsoft which said you can debug where this exception is occurring by:
Debug > Exceptions... and use the Find option to locate System.Runtime.InteropServices.COMException. Tick the option to break when it's thrown and then debug your application.

Related

Visual Studio 2015 Community Crashes on Startup

I've been using VS 2015 Community Edition without any issues for the past 2 months. Then one day it decided to crash (I wasn't doing anything when it crashed). After I tried starting it up again, it only gets to the home-page screen then crashes. No project is being opened, it crashes on its own.
Things I tried with no success:
Repairing the install.
Uninstalling then Reinstalling.
Running in /safemode (still crashes in safemode!)
I don't have anything custom installed (especially after the clean install).
At this point my only hope is re-installing windows (running Windows 7), and hoping the problem goes away then. Any other ideas, things I can try?
Here's the log dump from starting VS2015 in safemode (I wanted to post the contents here, but they exceed the allowed post size):
http://wikisend.com/download/447654/vs_log.txt
I did search through the log for error tags, and found the following instances:
<entry>
<record>2196</record>
<time>2016/03/16 19:49:43.330</time>
<type>Error</type>
<source>UserConnection</source>
<description>Failed to get IAccountManager from service provider.</description>
</entry>
<entry>
<record>2416</record>
<time>2016/03/16 19:49:44.273</time>
<type>Error</type>
<source>Extension Manager</source>
<description>Extension will not be loaded because an extension with the same ID &apos;Microsoft.Dev14.VsixTemplatesPackage.V2.443cca91-ec20-41e5-a165-f28e56b89650&apos; is already loaded at C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\EXTENSIONS\OZPNHXDR.G5H\...</description>
<path>C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\EXTENSIONS\NUGETIFIEDEXTENSIBILITYTEMPLATES\</path>
</entry>
<entry>
<record>2417</record>
<time>2016/03/16 19:49:44.274</time>
<type>Error</type>
<source>Extension Manager</source>
<description>Extension will not be loaded because an extension with the same ID &apos;Microsoft.VisualStudio.TeamFoundation.TeamExplorer.Extensions&apos; is already loaded at C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\EXTENSIONS\MKTRGVMI.4Y3\...</description>
<path>C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TEAMFOUNDATION\TEAM EXPLORER\</path>
</entry>
EDIT 1:
Following magicandre1981's advice I ran procdump, but the resulting file is 0.5 GB, so it's too much to upload. Here's a screenshot from the dump file. The exception seems to be 0xE0434352.
EDIT 2:
I looked at Event Viewer, and found the following Error related to the crash. Looks like the exception is caused by Microsoft.VisualStudio.Services.Experimentation.FlightsClient:
Application: devenv.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.NullReferenceException at Microsoft.VisualStudio.Services.Experimentation.FlightsClient+<ReadStreamFromRemoteAsync>d__20`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].MoveNext() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) at Microsoft.VisualStudio.Services.Experimentation.ShippedFlightsClient+<SetRemoteFlightsAsync>d__4.MoveNext() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) at Microsoft.VisualStudio.Services.Experimentation.VSExperimentationService+<<FlightDataCallback>b__33_0>d.MoveNext() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) at Microsoft.VisualStudio.Services.Experimentation.VSExperimentationService+<FlightDataCallback>d__33.MoveNext() at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_1(System.Object) at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() at System.Threading.ThreadPoolWorkQueue.Dispatch() at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
EDIT 3:
Searching for TestFlight related posts, I found the following from Microsoft (opting out of Experience Improvement Program). Looked very promising, but sadly didn't resolve my issue:
https://connect.microsoft.com/VisualStudio/feedback/details/2082049/crash-on-startup
I fixed the problem by installing Visual Studio 2015 Update 2 RC (I was running Update 1), and unchecking every single optional install feature (I just need C#/WPF). Chances are, simply installing Update 2 RC would fix the issue, but I've wasted too much time on it already to keep trying over and over again.
Here's a link to Update 2 RC:
https://www.visualstudio.com/en-us/news/vs2015-update2-vs.aspx

Visual Studio Online test runner can't load SpecFlow dll

I've added SpecFlow using Nuget and have a single spec (so it is a simple project). I've created a build in VS online 2015 using the web build editor.
Maybe it's a Nuget new build system issue? I'm not sure if it just a SpecFlow thing and haven't gotten a chance try straight MS unit tests yet.
An exception occurred while invoking executor
'executor://mstestadapter/v1': Could not load file or assembly
'TechTalk.SpecFlow, Version=1.9.0.77, Culture=neutral,
PublicKeyToken=0778194805d6db41' or one of its dependencies. The
system cannot find the file specified.
Here's a larger stack trace:
1. 2015-08-03T21:26:27.6325511Z Executing the powershell script: C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\tasks\VSTest\1.0.16\VSTest.ps1
2. 2015-08-03T21:26:28.4231183Z ##[debug]Calling Invoke-VSTest for all test assemblies
3. 2015-08-03T21:26:28.4481177Z Working folder: C:\a\14076a40
4. 2015-08-03T21:26:28.4481177Z Executing C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe "C:\a\14076a40\SpecByExample\SpecByExample.Specs\bin\Debug\SpecByExample.Specs.dll" "C:\a\14076a40\SpecByExample\SpecByExample.Specs\bin\Debug\SpecByExample.Specs.dll.config" "C:\a\14076a40\SpecByExample\SpecByExample.Specs\obj\Debug\SpecByExample.Specs.dll" /logger:trx
5. 2015-08-03T21:26:29.4654019Z Microsoft (R) Test Execution Command Line Tool Version 14.0.23107.0
6. 2015-08-03T21:26:29.4664025Z Copyright (c) Microsoft Corporation. All rights reserved.
7. 2015-08-03T21:26:29.4664025Z Starting test execution, please wait...
8. 2015-08-03T21:26:29.7564024Z Warning: Unable to load types from the test source 'C:\a\14076a40\SpecByExample\SpecByExample.Specs\obj\Debug\SpecByExample.Specs.dll'. Some or all of the tests in this source may not be discovered. If you are running unit tests for Windows Store apps and referencing custom WinMD type then please visit http://go.microsoft.com/fwlink/?LinkId=238340 for more info. Error details: System.IO.FileNotFoundException: Could not load file or assembly 'SpecResults, Version=0.1.0.7, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
9. 2015-08-03T21:26:29.7574029Z .
10. 2015-08-03T21:26:40.6922424Z Passed TheUserVisitsTheWebsite
11. 2015-08-03T21:26:41.3214684Z ##[error]Error: An exception occurred while invoking executor 'executor://mstestadapter/v1': Could not load file or assembly 'TechTalk.SpecFlow, Version=1.9.0.77, Culture=neutral, PublicKeyToken=0778194805d6db41' or one of its dependencies. The system cannot find the file specified.
12. 2015-08-03T21:26:41.3224680Z ##[error]
13. 2015-08-03T21:26:41.4936886Z Results File: C:\a\14076a40\TestResults\buildguest_TASKAGENT-0007 2015-08-03 21_26_40.trx
14. 2015-08-03T21:26:41.4956876Z Total tests: 1. Passed: 1. Failed: 0. Skipped: 0.
15. 2015-08-03T21:26:41.4966881Z ##[error]Test Run Failed.
16. 2015-08-03T21:26:41.4966881Z Test execution time: 11.8787 Seconds
17. 2015-08-03T21:26:41.7581094Z ##[error]VSTest Test Run failed with exit code: 1
18. 2015-08-03T21:26:41.7741099Z Publishing Test Results...
2015-08-03T21:26:43.0372165Z Test results remaining: 1
UPDATE: I disabled the SpecFlow test and added the simplest AboutController test possible (from file new project MVC in Visual Studio). I still get a 'could not load assembly problem. SpecByExample.Web is my MVC project in my solution.
2015-08-07T16:16:56.7251975Z ##[error]Error Message:
2015-08-07T16:16:56.7261978Z ##[error] Test method
SpecByExample.Web.Tests.Controllers.HomeControllerTests.AboutTest
threw exception: 2015-08-07T16:16:56.7261978Z
[error]System.IO.FileNotFoundException: Could not load file or assembly 'SpecByExample.Web, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null' or one of its dependencies. The system cannot
find the file specified.WRN: Assembly binding logging is turned OFF.
2015-08-07T16:16:56.7271982Z ##[error]To enable assembly bind failure
logging, set the registry value
[HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
2015-08-07T16:16:56.7271982Z ##[error]Note: There is some performance
penalty associated with assembly bind failure logging.
2015-08-07T16:16:56.7281979Z ##[error]To turn this feature off, remove
the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
2015-08-07T16:16:56.7281979Z ##[error] 2015-08-07T16:16:56.7291971Z
[error]Stack Trace: 2015-08-07T16:16:56.7291971Z ##[error] at SpecByExample.Web.Tests.Controllers.HomeControllerTests.AboutTest()
2015-08-07T16:16:56.7831986Z Results File:
C:\a\14076a40\TestResults\buildguest_TASKAGENT-0007 2015-08-07
16_16_56.trx 2015-08-07T16:16:56.7861977Z Attachments:
2015-08-07T16:16:56.7861977Z ##[error]Test Run Failed.
Here's a screenshot of my build definition:
In Run unit test step. click advance and give path to your packages folder. (if you are using nuget it will download all dependencies there) give it a try and let me know how it goes.

dll not loading- FileLoadException

The problem I am having is that I am getting a System.IO.FileLoadException when trying to load the RWLock.dll on a test box and Windows xp machines.
This is the exception that is thrown when it tries to load the dll on the windows 2003 server machine (most likely 32 bit):
System.IO.FileLoadException: A procedure imported by 'rwlock, Version=1.0.3889.27926, Culture=neutral, PublicKeyToken=null' could not be loaded.
File name: 'rwlock, Version=1.0.3889.27926, Culture=neutral, PublicKeyToken=null' ---> System.Runtime.InteropServices.COMException (0x8007007F): The specified procedure could not be found. (Exception from HRESULT: 0x8007007F)...
However, we have not had any problems trying to run this on a Windows 2007* server machine (64 bit).
Any ideas? Thanks in advance :)
*windows 2008(oops)
The error message is telling you that RWLock.dll tries to import a function that doesn't exist from another DLL. This probably means that RWLock is trying to import an API function that exists on the (I presume you meant instead of "Windows 2007 Server") Windows 2008 Server machine, but not on Windows 2003 or earlier.
You can use Dependency Walker to figure out what it's trying to load and where it's trying to find that missing function, but it won't help make it available on the Windows versions where it doesn't exist.
The other possibility is that RWLock has a dependency on another DLL that it provides, but you're not re-distributing it properly. Dependency Walker can help with this, too.

Upgrading App from .NET 3.5 to 4.0, COM fails now

I have an application that I am upgrading from the .NET 3.5 to the .NET 4.0 framework. It uses a COM library which is referenced. It works no problem in 3.5 but after converting to 4.0 I have issues getting the COM to work. The COM is from a 3rd party so we didn't develop it ourselves.
I get the following COM error (generic COM error, not specific to the COM object itself): hr = 0x8007000b
CLR gives me: 'The invocation of the constructor on type 'Skype_Business_Launcher.Main' that matches the specified binding constraints threw an exception.' Line number '3' and line position '5'.
And the C# logs:
=== Pre-bind state information ===
LOG: User = \phillip
LOG: DisplayName = Interop.SKYPE4COMLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : Skype Business Launcher, Version=1.0.5.0, Culture=neutral, PublicKeyToken=null.
LOG: This bind starts in default load context.
LOG: Using application configuration file:
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///bin/Debug/Interop.SKYPE4COMLib.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
I removed the pathname for security reasons but I have checked all the path information and it's all correct. Also the COM library file exists where it's pointing to. It's also copied to the OBJ folder within the project as well.
Originally I was getting an error about the COM library not supporting embedded types so I made "Embed Interop Types" false (it was true below) and the error went away but I'm not sure if thats connected to this error or not so I thought I'd mention it just in case.
Again, it works just fine with 3.5.
Thanks,
A shot in the dark: it looks like you are using the x64 version of the framework. Was that already the case with 3.5 ? And is the COM server a DLL or an EXE ?
If the COM server is a DLL, there needs to be a "bitness" match between the DLL and your program.
when you convert your project to 4.0 the IDE can perform a issue to convert COM library into 4.0.
when you convert your project to 4.0 remove com library then Re include it in your project then i thing it should be works.

Hosting PreviewHandlers on x64 gives REGDB_E_CLASSNOTREG

So this is the case,
I am using the http://www.codeplex.com/C4FDevKit,
I want to use the PreviewHandlerHost control in my desktop application
I successfully been able to do it and test it on XP 32, 64 bits and Vista 32, 64 bits
the issue only appeared on XP x64, This is the exception message
Unable to cast COM object of type
'System.__________ComObject' interface type
'MyApplication.IPreviewHandler'. This
failed because the QueryInterface call
on the COM component for the interface
with IID
'{8895B1C6-B41F-4C1C-A562-0D564250836F}'
failed due to the following error:
class not registered (Exception from
HRESULT: 0x80040154
(REGDB_______E___CLASSNOTREG)).
Please any help is appreciated.
And the file I was trying to preview was a Microsoft Word Document.
Go into the Project Properties for your desktop application, click the "Compile" tab and click "Advanced Compile Options...". Change "Target CPU" to x86, click OK, save, recompile and try again.
I've just hit this one myself - see COMException "Class not registered" on 64-bit Windows for more info.