Using c#, VS2005, and .NET 2.0. (XP 32 bit) This is a Winforms app that gets called by a VBA addin (.xla) via Interop libraries. This app has been around for a while and works fine when the assembly is compiled and executed anywhere other than my dev machine. On dev it crashes hard (in debugger and just running the object) with "Unhandled exception at 0x... in EXCEL.EXE: 0x...violation reading location 0x...
But here's the weird part:
The first method in my interface works fine. All the other methods crash as above. Here is an approximation of the 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 like some kind of environmental thing. Registry chundered? Could be code bugs, but it works fine elsewhere.