Not loading after upgrading to .NET 4.5

Mar 25, 2013 at 11:11 AM
I've been developing an excel addin on my machine. It has been working great until I upgraded to .NET 4.5.

Should excel dna work with .net 4.5? Or do I need to roll back to .net 4.0?

Thanks!
Coordinator
Mar 25, 2013 at 11:15 AM
Hi,

Excel-DNA works perfectly with .NET 4.5. I've had no issues reported, and some confirmations, and it is also the configuration I use.

One point to note - since .NET 4.5 is an in-place upgrade to .NET 4, the version has not changed, and you should still have the following in your .dna file:
<DnaLibrary RuntimeVersion="v4.0" >
...
This ensures that the .NET runtime with version 4.0 is loaded, which would be .NET 4 or .NET 4.5 depending on what is installed.

If you have any other issue with .NET 4.5, please write back so that we can take a closer look.

Regards,
Govert
Mar 25, 2013 at 11:22 AM
Yes, thats what I figured from what I could find online.

I'm not sure why my addin is no longer loading. I've rolled back to known working (and shipped to the client) versions and they also don't work. The only thing that has changed has been the upgrade to .NET 4.5.

Are there any tricks to debug why an excel dna addin doesn't load?

My dna file looks like this:
<DnaLibrary RuntimeVersion="v4.0" Name="Blast Visualizer" Language="C#">
  <Reference AssemblyPath="visualizerAddin.dll" />
  <![CDATA[

using System;
using ExcelDna.Integration.CustomUI;
using Visualizer;

[System.Runtime.InteropServices.ComVisible(true)]
public class Ribbon : ExcelRibbon
{
  public override void OnConnection(
      object Application,
      ExcelDna.Integration.Extensibility.ext_ConnectMode ConnectMode,
      object AddInInst,
      ref System.Array custom)
  {
      base.OnConnection(Application, ConnectMode, AddInInst, ref custom);
      Broker.Instance.ToString();
  }
  
  public void Visualize(IRibbonControl control) { Broker.Instance.Visualize(); }
  public void Clear(IRibbonControl control) { Broker.Instance.Clear(); }
}

]]>

  <CustomUI>
    <customUI xmlns='http://schemas.microsoft.com/office/2009/07/customui' loadImage='LoadImage'>
      <ribbon>
        <tabs>
          <tab id='blender' label='Blast Vis'>
            <group id='visualization' label='Visualization Tools'>
              <button id='vis' label='Visualize' size='large' onAction='Visualize' />
              <button id='clr' label='Clear' onAction='Clear' />
            </group >
          </tab>
        </tabs>
      </ribbon>
    </customUI>
  </CustomUI>
</DnaLibrary>
The ribbon tab is no where to be found...
Coordinator
Mar 25, 2013 at 11:28 AM
Hi,

Check that your add-in has not been marked as 'Disabled' by Excel. Go File->Options->Add-Ins, then Manage: Disabled Items and look in there.

Excel would mark your add-in as disabled if it gives error repeatedly during start-up, e.g. if you have broken ribbon xml. Once it is marked disabled, uninstalling and reinstalling does not fix it.

If this is not it, we have consider a more systematic approach.

-Govert
Mar 25, 2013 at 11:30 AM
No Excel tells me the addin is active actually. It is listed in the "Active Application Add-ins".
Coordinator
Mar 25, 2013 at 11:40 AM
Is this on Excel 2010?

Can you check whether the Excel-DNA ribbon samples still work?
Can you add a macro that check whether your library has loaded successfully - just to get past the ribbon? Something like:
public static class MyMacros
{
    [ExcelCommand(MenuName="Tests", MenuText="Test Broker")]
    public static void TestLibrary()
    {
        try
        {
            string x = Broker.Instance.ToString();
            XlCall.Excel(XlCall.xlcAlert, "Broker says: " + x);
        }
        catch (Exception ex)
        {
            XlCall.Excel(XlCall.xlcAlert, "Error: " + ex);
        }
    }
}
-Govert
Mar 25, 2013 at 11:49 AM
Yes this works perfectly. I see an "Add-ins" tab with the tests drop down. Calling the command executes my code.

I tried the "TestCSharp" sample and it doesn't appear in the ribbon either.
Coordinator
Mar 25, 2013 at 12:08 PM
Are you on Excel 2010? This is important because:
  • you are using the Excel 2010 namespace in your ribbon xml, and
  • Excel 2013 has some other issues that might be affecting you.
OK - so ribbons are not loading, but the rest seems fine.

I suggest:
  1. Go through the security settings. My machine has the following in the Trust Center:
  2. Add-Ins: None of the three options checked.
  3. ActiveX Settings: Prompt me before enabling all controls with minimal restrictions. The Safe Mode option is checked.
  4. Macro Settings: Disable all macros with notification. The "Trust access to the VBA project object model" option is checked.
  5. Protected View: Everything is checked.
    (Not sure what else might be important here.)
  6. Are you able to create subkeys in the HKCU\Software\Classes key in the registry? Open Regedit, navigate there and try to make a new subkey.
  7. Run Excel 'As Administrator' to test.
  8. Attach the Visual Studio debugger to Excel before loading your add-in. Look for suspicious debug messages in the Output window.
  9. Do you have an anti-virus program running. Disable it as a test. There used to be a problem with some McAfee versions.
Next you might need to rebuild Excel-DNA and debug the COM registration and add-in loading part...

-Govert
Mar 25, 2013 at 12:21 PM
I'm using excel 2010. Like I said, everything was working fine until I upgraded to .NET 4.5. That is the only thing I can think that has changed between this morning and this evening.

Regarding the trust center, I had almost the same settings you describe - I was missing the "Trust access to the VBA project object model" checkbox in the macro settings, but I turned that on and tried again.

That didn't help.

I am able to add reg keys to that location.

As for suspicious info in the output window, I've never paid it any attention till now, so I'm not sure what suspicious constitutes. This is what I get:
'EXCEL.EXE' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'EXCEL.EXE' (Managed (v4.0.30319)): Loaded 'ExcelDna.Loader'
'EXCEL.EXE' (Managed (v4.0.30319)): Loaded 'ExcelDna.Loader'
'EXCEL.EXE' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'EXCEL.EXE' (Managed (v4.0.30319)): Loaded 'ExcelDna.Integration'
'EXCEL.EXE' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'EXCEL.EXE' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'EXCEL.EXE' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'EXCEL.EXE' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'EXCEL.EXE' (Managed (v4.0.30319)): Loaded '1glguiz3'
'EXCEL.EXE' (Managed (v4.0.30319)): Loaded 'ExcelDna.DynamicDelegateAssembly'
The second from last line is weird - I have no idea what that is. Most everything else makes sense except for that...

I don't have anti virus running... Shame on me.

I'll try to rebuild the xll in debug and see what I can see. Although I'm not quite sure what to be looking for.

Thanks for your prompt help too by the way.
Coordinator
Mar 25, 2013 at 12:29 PM
That all looks fine.
The funny "1glguiz3" assembly you see being loaded is generated by Excel-DNA on the fly, to make the glue with Excel work.

Under a debug version I'd expect to see some error messages when the ribbon load fails.


(The issue might well be related to your .NET 4.5 installation, but no-one else has reporting anything similar, and it would help me more if we could actually track what the error is now, rather than just knowing 'there is sometimes a problem under .NET 4.5).

Thanks for your patience.

-Govert
Mar 25, 2013 at 12:41 PM
Can you point to any areas in the excel dna codebase I should be looking when trying to debug?

Any tips would be appreciated!
Mar 25, 2013 at 12:46 PM
The following messages seem suspect...
Got Application object: System.__ComObject
First-chance exception at 0x75f8c41f in EXCEL.EXE: Microsoft C++ exception: EECOMException at memory location 0x00303d90..
First-chance exception at 0x75f8c41f in EXCEL.EXE: Microsoft C++ exception: [rethrow] at memory location 0x00000000..
First-chance exception at 0x75f8c41f in EXCEL.EXE: 0xE0434352: 0xe0434352.
'EXCEL.EXE': Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\diasymreader.dll', Cannot find or open the PDB file
LoadComAddIn exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException: Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT))
   --- End of inner exception stack trace ---
   at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)
   at ExcelDna.Integration.CustomUI.ExcelComAddInHelper.LoadComAddIn(ExcelComAddIn addIn) in C:\Users\macaronikazoo\Downloads\ExcelDna-0.30\Source\ExcelDna.Integration\ExcelRibbon.cs:line 202
First-chance exception at 0x75f8c41f in EXCEL.EXE: 0xE0434352: 0xe0434352.
Integration.DnaLibraryAutoOpen Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException: Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT))
   --- End of inner exception stack trace ---
   at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)
   at ExcelDna.Integration.CustomUI.ExcelComAddInHelper.LoadComAddIn(ExcelComAddIn addIn) in C:\Users\macaronikazoo\Downloads\ExcelDna-0.30\Source\ExcelDna.Integration\ExcelRibbon.cs:line 216
   at ExcelDna.Integration.DnaLibrary.LoadCustomUI() in C:\Users\macaronikazoo\Downloads\ExcelDna-0.30\Source\ExcelDna.Integration\DnaLibrary.cs:line 343
   at ExcelDna.Integration.DnaLibrary.AutoOpen() in C:\Users\macaronikazoo\Downloads\ExcelDna-0.30\Source\ExcelDna.Integration\DnaLibrary.cs:line 303
   at ExcelDna.Integration.ExcelIntegration.DnaLibraryAutoOpen() in C:\Users\macaronikazoo\Downloads\ExcelDna-0.30\Source\ExcelDna.Integration\ExcelIntegration.cs:line 146
Exit Integration.DnaLibraryAutoOpen
Anything there make sense?
Coordinator
Mar 25, 2013 at 12:49 PM
First just make a debug version (the .xll should be about 800-900 KB) and use that instead of the regular .xll. Again attach a debugger and look for the Output.

In the Excel-DNA code, the crucial part is in the ExcelComAddInHelper.LoadComAddIn, in the file ExcelRibbon.cs. But any exceptions from there should be written to Output already.

-Govert
Coordinator
Mar 25, 2013 at 1:02 PM
Edited Mar 25, 2013 at 1:02 PM
OK, the error is : HRESULT: 0x80004004 (E_ABORT), probably when we're calling Connect.

I've never heard of this error, and don't know what it might mean.


The reflection-based code goes something like this:
comAddIns = Application.ComAddIns
comAddIns.Update()
comAddIn = comAddIns("OurRibbon.TheProgId")
comAddIn.Connect = True   <<<<<<<<< Error here....
You could uncomment some of those Debug.Print statements to get the precise line where the error is thrown.
You could try to make a COM add-in in another way and see whether that works.

Try to reboot the PC (grasping at straws, I know...)

-Govert
Mar 26, 2013 at 3:01 AM
Yeah tried the 'ol reboot... No dice.

So I've uncommented the debug.Print statements in ExcelComAddInHelper.LoadComAddIn but that code doesn't even seem to get hit. Visual studio tells me the assembly isn't loaded when I set a breakpoint and I can't see the debug print statements echoed anywhere either.

I'm not quite sure how the exceldna.integration dll gets loaded by the xll anyway...
Mar 26, 2013 at 3:36 AM
Sorry, my bad, I do get output from uncommenting those lines - but I still don't understand why I can't set breakpoints in that code...
Got Application object: System.__ComObject
Got COMAddins object: System.__ComObject
Updated COMAddins object with AddIn registered
Got the COMAddin object: System.__ComObject
First-chance exception at 0x75f8c41f in EXCEL.EXE: Microsoft C++ exception: EECOMException at memory location 0x00144360..
First-chance exception at 0x75f8c41f in EXCEL.EXE: Microsoft C++ exception: [rethrow] at memory location 0x00000000..
First-chance exception at 0x75f8c41f in EXCEL.EXE: 0xE0434352: 0xe0434352.
'EXCEL.EXE': Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\diasymreader.dll', Cannot find or open the PDB file
LoadComAddIn exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException: Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT))
   --- End of inner exception stack trace ---
   at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)
   at ExcelDna.Integration.CustomUI.ExcelComAddInHelper.LoadComAddIn(ExcelComAddIn addIn) in C:\Users\macaronikazoo\code\ExcelDna\Source\ExcelDna.Integration\ExcelRibbon.cs:line 202
First-chance exception at 0x75f8c41f in EXCEL.EXE: 0xE0434352: 0xe0434352.
Integration.DnaLibraryAutoOpen Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException: Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT))
   --- End of inner exception stack trace ---
   at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)
   at ExcelDna.Integration.CustomUI.ExcelComAddInHelper.LoadComAddIn(ExcelComAddIn addIn) in C:\Users\macaronikazoo\code\ExcelDna\Source\ExcelDna.Integration\ExcelRibbon.cs:line 216
   at ExcelDna.Integration.DnaLibrary.LoadCustomUI() in C:\Users\macaronikazoo\code\ExcelDna\Source\ExcelDna.Integration\DnaLibrary.cs:line 343
   at ExcelDna.Integration.DnaLibrary.AutoOpen() in C:\Users\macaronikazoo\code\ExcelDna\Source\ExcelDna.Integration\DnaLibrary.cs:line 303
   at ExcelDna.Integration.ExcelIntegration.DnaLibraryAutoOpen() in C:\Users\macaronikazoo\code\ExcelDna\Source\ExcelDna.Integration\ExcelIntegration.cs:line 146
Exit Integration.DnaLibraryAutoOpen
You can see the additional lines that weren't' there before. Not terribly useful to me however. Any ideas?
Got COMAddins object: System.__ComObject
Updated COMAddins object with AddIn registered
Got the COMAddin object: System.__ComObject
Mar 26, 2013 at 4:26 AM
I also get this:
CreateFullTrustSandbox - sandbox AppDomain created. Id: 3
'EXCEL.EXE' (Managed (v4.0.30319)): Loaded 'ExcelDna.Loader', Symbols loaded.
'EXCEL.EXE' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'EXCEL.EXE' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'EXCEL.EXE' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Initialize - in sandbox AppDomain with Id: 3, running on thread: 1
InitializationInfo Address: 0x106236464
'EXCEL.EXE' (Managed (v4.0.30319)): Loaded 'C:\Users\macaronikazoo\Dropbox\code\blast_visualizer\build\ExcelDna.Integration.dll'
AppDomain Id: 3 (Default: False)
In XlAddIn.XlAutoOpen
'EXCEL.EXE' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'EXCEL.EXE' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
GetResourceBytes for resource __MAIN__ of type 1
LoadResourceBytes for resource __MAIN__ of type DNA
Resource not found - resource __MAIN__ of type DNA_LZMA
'EXCEL.EXE' (Managed (v4.0.30319)): Loaded 'hne0ls01'
'EXCEL.EXE' (Managed (v4.0.30319)): Loaded 'ExcelDna.DynamicDelegateAssembly'
Register - XllPath=C:\Users\macaronikazoo\Dropbox\code\blast_visualizer\build\visualizerAddin.xll, ProcName=f0, FunctionType=, MethodName=TestLibrary - Result=-1658454015
Coordinator
Mar 26, 2013 at 6:01 AM
Hi,

OK - this confirms the earlier suspicion. Excel-DNA is calling this code (VBA equivalent):
set comAddIns = Application.ComAddIns
comAddIns.Update()
set comAddIn = comAddIns("OurRibbon.TheProgId")
comAddIn.Connect = true   <<<<<<<<< Error here....
And you're get an unusual exception in the comAddIn.Connect=True call. The error is a COM error 'Operation Aborted' (HRESULT: 0x80004004 (E_ABORT)`), which the internet has little to say about and I have never heard of.
Why would Excel 'abort' loading the add-in?

You say this started after loading .NET 4.5, but I've not heard any other reports of issues going to .NET 4.5.

Maybe you can make a vanilla COM add-in somehow, and check that this add-in loads properly. This would reveal if there might be a problem with the Excel installation. You can then run the COMAddIn load code above from VBA. Of this fails too, we've made big progress.

(Debugging Excel-DNA is not likely to reveal more. But to do so you need to make sure the whole project is rebuilt, then attach to the running Excel with the right 'managed debugger' version. I normally copy my add-in files into the Source\ExcelDna\Debug directory, and rename the .dna to ExcelDna.dna. That way the Excel-DNA files run just as they got copied to the Debug directory.)

You could also try to repair Office, or install SP1 if you haven't yet.

-Govert
Apr 3, 2013 at 6:57 AM
Edited Apr 3, 2013 at 7:51 AM
I've been away from this problem for a bit. But I'm coming back to it now and have done a little more debugging.

-edit- nevermind this post was incorrect... Still digging.

So it looks like you're exactly right, an exception is being thrown when it tries to invoke the Connect method on the com addin.
[code]
Here is my callstack at the time:
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)
at ExcelDna.Integration.CustomUI.ExcelComAddInHelper.LoadComAddIn(ExcelComAddIn addIn)[/code]

I'll try the repair thing.
Apr 5, 2013 at 11:04 AM
The repair thing doesn't work. And installing SP1 tells me that I have no applications that SP1 affects (I only have excel and word installed)...

So back to square 1 sadly... :(

Are there any other ways to get a ribbon loading in excel without using VSTO?
Coordinator
Apr 5, 2013 at 11:27 AM
Hi,

As I understand it now, the problem has nothing to do with the ribbon. Your Excel is failing to load a COM add-in. You can make an office COM add-in using one of the VS templates, and see whether that can be loaded with the same code that's failing now:
comAddIns = Application.ComAddIns
comAddIns.Update()
comAddIn = comAddIns("YourTestAddIn.ProgId")
comAddIn.Connect = True   <<<<<<<<< Error here....
Excel 2010 is certainly updated by the Office 2010 SP1. Perhaps you had it installed already, or the SP1 version (32-bit or 64-bit) did not match the Office version.

You might also try your add-in on another machine, or uninstall and re-install Office completely.

There are other ways to get a ribbon working, but that will not resolve all your Excel-DNA issues, from my understanding of the error you show.

-Govert
Apr 5, 2013 at 4:52 PM
Hi there,

Sorry to hear that you are seeing issues. I am from Microsoft .NET Framework Compatibility team. I would like to understand this better. I would like to rule out any machine specific issues or install issues with Office or .NET. Unfortunately, the best way to isolate the problem is to try it on a fresh machine. Could you do the following?
  1. Create fresh Window 7 machine with .NET4 installed on it (it would be perfect if you can re-install OS when you try this). Verify that your scenario works correctly.
  2. Install .NET 4.5 (do not install anything else). Verify whether your scenario works correctly (exact scenario that you tried in #1).
If these steps would take a lot of time for you, just email me (netfx45compat at Microsoft dot com) & I'll have someone on my team help try out these steps (I'll need your add-in, and exact steps to reproduce the issue)

Once the issue is isolated, I'll take deeper look.

Sincerely
--Varun
Microsoft .NET Framework
Apr 6, 2013 at 2:55 AM
@govert - Yes maybe I already had the SP1 installed, I'm not even sure how to tell. If it was installed, it hadn't been done by me, but presumably windows update would have taken care of it. How does one tell?

I don't actually have a spare machine with office installed on it - which is definitely something I need to fix. I will try on a friend's computer perhaps.

Regarding other ways to get a ribbon working, I'd love to hear them. Excel DNA is letting me load my addin with minimal user privileges, so thats awesome. And the Add-Ins tab that it adds is fine and working, but ideally if I can get those buttons in a ribbon tab thats all I need.

I'll let you know when I get a chance to try it on another computer. Presumably it'll work fine, but I'll let you know either way.


@Varun - I've sent you an email, thanks for responding!
Apr 9, 2013 at 9:48 PM
Hi Hamish,

I tried your add-in on a fresh Windows 7 machine with Excel 2007 and Excel 2010. Your add-in works correctly on excel 2007 with .NET Framework 4 and after upgrade to .NET4.5. So it's NOT a .NET Framework 4.5 issue.

But it does not work correctly with excel 2010 and .NET Framework 4.

I get the following message – “ The you are trying to open, is in a different format than specified by the file extension”

Did you also see this error?

Varun
Coordinator
Apr 9, 2013 at 10:31 PM
Edited Apr 9, 2013 at 10:33 PM
Hi Varun,

(I develop the Excel-DNA add-in framework.)

Is it possible that you're trying to open a 32-bit add-in on a 64-bit Excel installation? You need a separate binary for the 64-bit version of Excel.

I've also had no other reports of issues related to .NET 4.5 with Excel-DNA, and certainly had some confirmations of places where the upgrade was made with no problems.

-Govert
Apr 30, 2013 at 1:12 PM
macaronikazoo wrote:
I've been developing an excel addin on my machine. It has been working great until I upgraded to .NET 4.5.

Should excel dna work with .net 4.5? Or do I need to roll back to .net 4.0?

Thanks!

I have experienced the same problem. Having a working Excel-DNA application exposing UDFs and a ribbon, I made some code changes and 'upgraded' target platform to .NET 4.5. Afterwards, the add-in was not available although recognizable by Excel.

To cut it short, the abovementioned code changes included adding a test project to my solution.
After unloading the test project, the add-in become alive and also debuggable.
(In-between I had changed the target platform to .NET 4.0 for all C#-Projects but in vain.)
Now I had a working add-in.
Encouraged, I then changed the target platform to .NET4.5 for all C#-Projects, and it still works fine.

So it seems like the presence of the test project somehow interfers with the proper execution of the add-in.
  • Mogens
Coordinator
Apr 30, 2013 at 2:07 PM
Hi Mogens,

If you have a solution that exhibits the problem, and that you can send to me, I'd be happy to have a look.

Regards,
Govert
Apr 30, 2013 at 9:12 PM

Hi Govert

I will get back to you tomorrow evening 1st of May.

I have iterated over the apparent cause and there is definitely something spooky going when dealing with a Test project within the solution. It also seems that the Debug Start Action (Start project or Start external program) has its say.

The issue is to find a consistent way to reproduce the problem.

For instance, when I reload the Test project and run one of the tests, it will throw a TypeInitializationException (see snapshot below).

But after some iterations, I am able to arrive at a functional stage, where I can run Tests and also perform a debug session invoking Excel.

I only perform Rebuilds and change the Debug Start Action.

Currently, I am not able to reproduce the problem, although it nagged me for a day.

So I am trying to sort things out to give you a recipe for reproducing the situation.

For now, I have attached the zipped solution, which I have unpacked and tested (positively) from another file location.

If you wonder about the application, it computes properties of pure water as used within power plant circuits.

IAPWS97 stands for “Intl Association of Properties of Water and Steam 1997”.

Best regards

Mogens

Coordinator
Apr 30, 2013 at 10:12 PM
Hi Mogens,

I'm not sure about the attachment or screenshot.

Perhaps you can mail me directly at govert@icon.co.za ?

Regards,
Govert
Jun 21, 2013 at 8:00 PM
Was this ever resolved? I've been running into this problem everyone once in a while and just have to rebuild the whole solution.
Jun 22, 2013 at 9:49 AM
Hi Jon

Govert actually pointed me to a solution (see quoted text below).
In short, I had copied the "ExcelDna.Integration.dll" into the same directory as the .xll file.
When I removed that copy, it just worked fine.

[Quote from Govert]

OK - I recompiled your solution, changed the debug paths in the AddIn project, and run it. It loads in Excel, I see a ribbon and everything seems to work fine, including debugging. I also ran the tests, and all seemed well.

I might be able to shed some light on the error though. The error is that the assembly ExcelDna.Integration.dll is not found. This is the Excel-DNA assembly that you are referencing from your add-in project. The assembly is somewhat special in how it works when your add-in is hosted by the Excel-DNA runtime .xll: A copy of ExcelDna.Integration.dll is embedded into the .xll file, so you never need to redistribute ExcelDna.Integration.dll - the right assembly is loaded at runtime from the embedded copy. Sometimes, if you do have an extra copy of the ExcelDna.Integration.dll in the same directory as the .xll, it can cause the problems that you describe - the ribbon is not loaded etc. To prevent this kind of problem, the NuGet package marks the reference to ExcelDna.Integration.dll as "Copy Local=false" meaning that it won't be copied to the output directory, which is correct. I guess that in some of your testing situations, you are causing a copy of ExcelDna.Integration.dll to land in the output directory next to the .xll causing trouble. Or the other hand, if you are loading your add-in .dll for testing, you do need a copy of ExcelDna.Integration.dll, since your add-in depends on it, and when testing it is not 'magically' loaded by the .xll.

So I suggest that next time you have trouble,
  1. If running in Excel, check that there is no ExcelDna.Integration.dll next to your .xll in the output directory.
  2. If running the testing, check that the ExcelDna.Integration.dll is present in the directory where your tests are running.
I'm not what what a complete configuration is that has everything in the right place, but the solution as you sent it to me seems to work fine.

I hope that gives you some ideas. Let me know if you need any further help.
[End of quote]