Excel Addin Access Violation

Using C #, VS2005 and .NET 2.0. (XP 32 bit) This is a Winforms application that is called by a VBA (.xla) application through Interop libraries. This application has existed for some time and works great when the assembly compiles and runs in any other place except my dev machine. On dev, it will work hard (in the debugger and the object is just running) using "Unhandled exception at 0x ... in EXCEL.EXE: 0x ... place to detect 0x errors ...

But here is the weird part:

The first method in my interface works fine. All other methods work as described above. Here is a sample code:

[Guid("123Fooetc...")] [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] public interface IBar { [DispId(1)] void ThisOneWorksFine(Excel.Workbook ActiveWorkBook); [DispId(2)] string Crash1(Excel.Workbook ActiveWorkBook); [DispId(3)] int Crash2(Excel.Workbook activeWorkBook, Excel.Range target, string someStr); } [Guid("345Fooetc..")] [ClassInterface(ClassInterfaceType.None)] [ProgId("MyNameSpace.MyClass")] public class MyClass : IBar { public void ThisOneWorksFine(Excel.Workbook ActiveWorkBook) {...} string Crash1(Excel.Workbook ActiveWorkBook); {...} int Crash2(Excel.Workbook activeWorkBook, Excel.Range target, string someStr); {...} } 

It seems to be a bit of an environmental one. The registry rang out? It may be a code error, but it works great elsewhere.

0
source share
3 answers

I had problems in this scenario with Office 2003 in the past. Some things that helped:

  • Installing Office 2003 Service Pack 2 (SP2) stopped some of the crashes that occurred when exiting Excel.

  • Installing Office 2003 Service Pack 3 fixes an issue using XP styles in VSTO2005 (not here)

  • Executing Excel Code VBA CodeCleaner http://www.appspro.com/Utilities/CodeCleaner.htm periodically helps prevent accidental crashes.

  • Accessing Excel objects from multiple threads will be dodgy, so I hope you don't.

If you have the opportunity, you can also try opening a business with Microsoft PSS. They are very good if you can reproduce the problem. And in most cases, this type of error is a mistake, so you won’t be paid for it :)

+2
source

Is your machine for Win64? I had problems with win64 builds applications that go away if you install the build platform on x86.

0
source

Is your dev machine a different version of Office than other machines? I know that PIAs are different. For example, if you are running Office 2003 and testing Office 2007 (or vice versa), you will run into problems.

0
source

All Articles