System.Runtime.InteropServices.COMException

  • Thread starter Thread starter Matthias Tessmann
  • Start date Start date
M

Matthias Tessmann

Hello all!

I hope this is the right place to post this question.
My problem is that I cannot run a .NET application anymore.
When I start an application that uses .NET, it runs and after 3
seconds or so I get an

System.Runtime.InteropServices.COMException
with the
Additional information: Cannot create a file when that file already exists.

I've tried to reinstall Visual Studio and the .NET SDK but always the same.
I don't even use COM or Interop. This is a message I get when I create a
simple
new Windows Forms application and click "start"...

..NET worked when I first installed my development machine, but I usually
create native code, so I dont know since when .NET stopped working.

Maybe somebody here has experienced the same error and can help me out?

Thank you in advance.

Greetings,
Matthias
 
Hello Matthias,

Thanks for your post. As I understand, the problem you are facing is that
you fails to execute a WinForm app with the exception COMException --
"Cannot create a file when that file already exists". Please correct me if
there is any misunderstanding. I think more information is needed before
moving forward:

1. What's the version of your VS .NET, 2002 or 2003?

2. Does the problem occurs to other project say, .NET Console application,
ASP .NET Web application?

3. What's the detailed information of the exception? For example, the
content of call stack.

4. You can use Filemon to monitor the file access to check which file may
cause the problem. You can download the tool at
http://www.sysinternals.com/ntw2k/source/filemon.shtml.

5. When you need to uninstall VS .NET, please refer to the following KB
article which is able to remove the product cleanly from the system.

HOW TO: Remove Microsoft Visual Studio .NET 2003
http://support.microsoft.com/?id=824642

HOW TO: Manually Remove Visual Studio .NET 2002 Components
http://support.microsoft.com/default.aspx?scid=kb;EN-US;320114

I look forward to your response.

Have a nice day! :-)

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hello,

thanks for your quick reply.
1. What's the version of your VS .NET, 2002 or 2003?

I am using VS .NET 2003 with .NET Framework v1.1.4322.
2. Does the problem occurs to other project say, .NET Console application,
ASP .NET Web application?

First of all, the Problem does not only occurr on my own projects, but
everything
using System.Windows.Forms, or as I show later, the .NET Framework in
general.

For example, the "Microsoft .NET Framework 1.1
Wizards" tool from "Administrative Tools" fails with exactly the same
reason.

The NVIDIA SDK Browser, from NVIDIAS new SDK 7 also fails with the same
error but this time with the "Additional Information: Unknown Error".

Console applications are also affected. For my little testing app, the error
is:

An unhandled exception of type 'System.Runtime.InteropServices.COMException'
occurred in Unknown Module.

Additional information: Cannot create a file when that file already exists.

Note here the "Unknown Module". I think the code to reproduce the error is
small enough that I can post it, so you can see, I am doing nothing
extraordinary:

static void Main(string[] args)
{
System.Console.WriteLine("Hello World");
System.DateTime d1 = System.DateTime.Now;
d1 = d1.AddSeconds(60);
while (true)
{
System.DateTime d2 = System.DateTime.Now;
if (RoughlyEquals(d1,d2,10,60*60*2))
{
System.Console.WriteLine("Time Hit...");
break;
}
}
}

Where "RoughlyEquals" is the sample function provided in the MSDN Library
on the manual page for DateTime.

The call stack for this app is:

7ffe0304()
ntdll.dll!77f5c534()
kernel32.dll!_WaitForSingleObjectEx@12() + 0x8b
kernel32.dll!_WaitForSingleObject@8() + 0xf
mscorwks.dll!792952f6()
mscorwks.dll!792967c0()
mscorwks.dll!7924629f()
mscorwks.dll!7939f184()
mscorwks.dll!7939f32a()
mscorwks.dll!792adb55()
kernel32.dll!_IsBadReadPtr@8() + 0x5f
mscorwks.dll!792adc41()
nview.dll!1009a575()
kernel32.dll!_UnhandledExceptionFilter@4() + 0x60
kernel32.dll!_BaseProcessStart@4() + 0x12334

Note that the waiting is neccesarry to reproduce the error. If I just write
a "Hello World" it works just fine and exits. Only when the application runs
"long enough", the COMException occurrs.

I am really not into ASP .NET, so I don't have tried that one. But since
the console app fails I strongly assume that this will fail, too. If its
absolutely
crucical for you to know, I will produce a sample.
3. What's the detailed information of the exception? For example, the
content of call stack.

The exact error is (for the System.Windows.Forms app now) :

An unhandled exception of type 'System.Runtime.InteropServices.COMException'
occurred in system.windows.forms.dll

Additional information: Cannot create a file when that file already exists.

This is the call stack:

system.windows.forms.dll!System.Windows.Forms.Application.ComponentManager.S
ystem.Windows.Forms.UnsafeNativeMethods+
IMsoComponentManager.FPushMessageLoop(int dwComponentID, int reason, int
pvLoopData) + 0x53e bytes

system.windows.forms.dll!ThreadContext.RunMessageLoopInner(int reason,
System.Windows.Forms.ApplicationContext context) + 0x15f bytes
system.windows.forms.dll!ThreadContext.RunMessageLoop(int reason,
System.Windows.Forms.ApplicationContext context) + 0x45 bytes
system.windows.forms.dll!System.Windows.Forms.Application.Run(System.Windows
..Forms.Form mainForm) + 0x34 bytes
WindowsApplication1.exe!WindowsApplication1.Form1.Main() Line 67 C#

This is all information I can get.
I assume there is more wrong about this, because I am not able to Debug .NET
Applications
with Visual Studio as it seems. At least not in the instance of it that I
used to run the App, for I
get the message JIT Debugging would not be enabled, though it is. Stepping
into the code or halting
at Breakpoints also does not work - like say I never set a Breakpoint or hit
F11 but just clicked run.

I just got to the call stack by attaching a new Visual Studio instance.
4. You can use Filemon to monitor the file access to check which file may
cause the problem. You can download the tool at
http://www.sysinternals.com/ntw2k/source/filemon.shtml.

I have tried that, but I could not find an error that suggests an already
existing file.
What I found is some PATH NOT FOUND and BUFFER OVERFLOW errors, but
I cannot tell if that has anything to do with it, I paste some of the
relevant lines for the ConsoleApplication
here:

ConsoleApplicat:2904 OPEN
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\en\MSCORRC.DLL
PATH NOT FOUND Options: Open Access: All

ConsoleApplicat:2904 OPEN
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\en-US\MSCORRC.DLL
PATH NOT FOUND Options: Open Access: All

ConsoleApplicat:2904 QUERY INFORMATION
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\MSCORRC.DLL
BUFFER OVERFLOW FileFsVolumeInformation

I know .NET applications worked fine, when I once did a fresh setup of my
machine in January.
Since then I have installed lots of additional Programs and tools - and used
..NET only sparely,
so I cannot tell if anything of that caused my trouble. Most of the time,
I'm working with native
applications, and I have no problem with them - debugging a native app also
works as expected in
Visual Studio.

I would be glad if you can help me to resolve this issue, so I can avoid
reinstalling my machine and
I hope the information I provided will suffice - let me know if I forgot
something.

Greetings,
Matthias
 
Hi Matthias,

Thanks a lot for your information. I noticed that there is a third-pary
nview.dll in the call stack. I suggest you to reboot your system into
Windows Safe-Mode and then check if you can reproduce the problem.

I look forward to hearing from you.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hello Tian Min,
Thanks a lot for your information. I noticed that there is a third-pary
nview.dll in the call stack. I suggest you to reboot your system into
Windows Safe-Mode and then check if you can reproduce the problem.

Finally that hint got me to resolve the problem, though it was not caused
by nview.dll (which would be a mess since that is part of my display
driver).

I started in Safe-Mode and .NET worked as expected - thus I started to
track down running programs and loaded drivers which might have something
to do with it.

As it turned out, I have been running monitoring software for my ISDN card
to watch over outgoing connections - and that one caused that exception...
weird, isn't it?
If I have some time, I will see if I can figure out what exactly that thing
was doing, for now I just leave it disabled which will do as I don't use
ISDN very
much now so removing the cable will be just as safe :)

Anyway, without your help I'd never suggested that one beeing a problem,
so I thank you very much for pointing me in the right direction and finally
resolve
the issue.

Best regards,

Matthias
 
Back
Top