A Day in the Life

A day in my life. Thoughts on leadership, management, startups, technology, software, concurrent development, etc... Basically the stuff I think about from 10am to 6pm.

1/18/2006

Software: Running Excel with .NET 1.1 Code-Behind

Working programmatically with Microsoft Excel is always fun because it’s sort of the ugly stepchild. I’ve been working on making sure that our samples still work in Visual Studio 2003 and suddenly, **throat clearing**, I was no longer able to debug the Excel with code-behind sample. So of course I dug around for answers...

I turned up this group posting: “VS 2003 to VS 2005 UPGRADE w/Excel 2003, VSTO”. Ken states that you can experience Excel debugging problems if you have both Visual Studio 2003 and Visual Studio 2005 installed. He suggests either porting the application to Visual Studio 2005 or creating an Excel config file specifying that you want to use .NET 1.1 for the Excel application and consequently debugging. I’m going to have to create an application config file to debug in Visual Studio 2003 and remember to remove it when I port the sample to the .Net 2.0 version and test in Visual Studio 2005. What a pain.

So the next thing to figure out was what’s in an excel.exe.config file and where does it live. This information can be found at ”Side-by-Side Execution of the .NET Framework”.

By putting the file excel.exe.config in the same directory as my excel.exe file I am able to once again use Visual Studio 2003 to debug an Excel application.

And here are the contents of my excel.exe.config:
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v1.1.4322"/>
</startup>
</configuration>
And I am now able to debug my Excel sample.

But that wasn’t all; there is more to Excel with .NET 1.1 code-behind. I wasn’t able to instantiate an object that was defined by the Digipede Framework. The DigipedeClient object in particular. I got the following message:
An unhandled exception of type 'System.Security.SecurityException' occurred in digipede.framework.dll

Additional information: Request for the permission of type System.Security.Permissions.StrongNameIdentityPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
What this means is that my Excel project wasn’t given the permissions it needed to run. So I had to go into the .NET Configuration 1.1 Wizard and add my Excel project under “Runtime Security Policy\User\Code Groups\All_Code\Office_Projects”. Once I had the correct .NET libraries in use and the security policy problem cleared up, I was good to go.

3 Comments:

At October 02, 2006 11:32 PM, Anonymous Anonymous said...

Thank you very much. Your post has been very usefull to me.
Regards.
Nico

 
At May 28, 2007 8:07 AM, Anonymous Anonymous said...

Hi !

I have implemented a RTDServer for Excel in C#. While working on my laptop the application works like a charm but, to my rue, when i port the same solution to my desktop it starts giving following problem...

Unable to start debugging. Check for one of the following.

1. The application you are trying to debug uses a version of the Microsoft .NET Framework that is not supposed by the debugger.

2. The debugger has made an incorrect assumption about the Microsoft .NET Framework version your application is going to use.

3. The Microsoft .NET Framework version specified by you for debugging is incorrect.

I have been fooling around to get done with this fault with no success. I will be very thankful if you have any idea which can help me out.

Below are my laptop and desktop environment details...

==================
Laptop Configuration
==================

Microsoft Windows XP Professional
Version 5.1.2600 Service Pack 2 Build 2600
x86-based PC

Visual Studio 2005
8.0.50727.42 (RTM.050727-4200)
Microsoft .NET Framework Version 2.0.50727

Microsoft Office Excel 2003 (11.8134.8132) SP2
Part of Microsoft Office Professional Edition 2003

===================
Desktop Configuration
===================

Microsoft Windows XP Professional x64 Edition
Version 5.2.3790 Service Pack 1 Build 3790
x64-based PC

Visual Studio 2005
8.0.50727.42 (RTM.050727-4200)
Microsoft .NET Framework Version 2.0.50727

Microsoft Office Excel 2003 (11.6560.6568) SP2
Part of Microsoft Office Professional Edition 2003

Thanks for your time.

 
At May 28, 2007 8:54 PM, Blogger Kim Greenlee said...

Well, you really didn't give me much to work with here. I suggest that you try your code on a 32-bit version of Windows. If it works there, then I would spend some time investigating what's going on from a 64-bit perspective.

Look at this post for some ideas.

 

Post a Comment

Links to this post:

Create a Link

<< Home