Unable to change the LoadBehaviour value from 2 to 3 in Registry

Add-in Express™ Support Service
That's what is more important than anything else

Unable to change the LoadBehaviour value from 2 to 3 in Registry
 
Nikhil Salvi




Posts: 12
Joined: 2010-01-14
Hello,

LoadBehaviour value in Registry does not change from 2 to 3.
I did following:
1) VSTO addin is loaded properly initially. The value in registry is 3.
2) Go to COM Add - Ins in the word application.
3) Uncheck the check box for the my add in. The value in the registry changes from 3 to 2.
$) Close the word application.
6) Open the word application again.
7) Add in does not load.
8) Go to COM Add - Ins in the word application.
9) Check the check box for the my add in. The value in the registry does not change from 2 to 3. It remains 2. Because of which add in does not load.
10) On the COM Add-Ins window following message is displayed :
Load Beh * avior : Not loaded. A runtime error occurred during the loading of the COM Add-In.

Can anyone please suggest, the solution for the above mentioned problem. How to change the value of LoadBehavior in Registry back to 3?

Thanks
Posted 14 Jan, 2010 08:59:08 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hi Nikhil,

The reason is described in your post, it is "A runtime error occurred during the loading of the COM Add-In". This error occurs if there's an unhandled exception at add-in startup. Also check if you supply all assemblies required for the add-in.


Andrei Smolin
Add-in Express Team Leader
Posted 14 Jan, 2010 09:12:44 Top
Nikhil Salvi




Posts: 12
Joined: 2010-01-14
Thanks Andrei for quick reply.
Posted 15 Jan, 2010 01:31:38 Top
Nikhil Salvi




Posts: 12
Joined: 2010-01-14
Hello,

In Word Add-In Start up try catch blocks are used. And all required assemblies are provided.
And there is no exception in the start up code.
But still the same error is produced. What can be the reason?

Thanks.
Posted 15 Jan, 2010 05:17:32 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hi Nikhil,

Check if you supply all assemblies required for your add-in.


Andrei Smolin
Add-in Express Team Leader
Posted 15 Jan, 2010 06:01:59 Top
Nikhil Salvi




Posts: 12
Joined: 2010-01-14
Hi Andrei,

Sorry for replying so late. I was engaged with some other issues.

I used Fusion logs to find out what exactly happens. In one of the generated log file, I found that, SmartTag.dll is creating an problem. We are using SmartTag and registering using Regasm, but still it is causing an error.

Is there any specific way to register or use SmarTag dll with Office 2007?

Thanks a lot Andrei.
Posted 02 Feb, 2010 04:35:45 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hi Nikhil,

I suggest that you isolate the problem first. Try commenting out the use of smart tag in your add-in project and make sure that you create all required permissions (if you use VSTO 2005 SE). Note that the VSTO edition of Add-in Express doesn't support creating smart tags so I'm unable to help you with this.


Andrei Smolin
Add-in Express Team Leader
Posted 02 Feb, 2010 10:54:09 Top
Nikhil Salvi




Posts: 12
Joined: 2010-01-14
Thanks Andrei,

We have two classes in our project for SmartTag Recognizers and SmartTag Actions.
Both of these classes have GUID which we enter in the registry at following location:
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\Smart Tag\Recognizers and HKEY_CURRENT_USER\Software\Microsoft\Office\Common\Smart Tag\Actions respectively.

I removed the GUID of both the classes from above mentioned locations. And then I removed the Add in and closed the word application. On opening it again when I tried to load the Add-In, it got loaded successfully. Offcourse at the loss of SmartTag recognizer and action functionality.

Does this mean is there any problem in these classes?

Also, I tried to add full trust to SmartTag.dll using caspol -af. But because of the strong name was not associated to the dll it did not allowed to add full trust. So I am working out on it.

Thanks and Regards,
Nikhil
Posted 02 Feb, 2010 22:40:01 Top
Nikhil Salvi




Posts: 12
Joined: 2010-01-14
Hi Andrei,

I was unable to debug my project. Today I tried to debug again. When I reproduced scenario, I got message(i.e. exception) :


And on clicking on details button, I got following:
Customization could not be loaded because the application domain could not be created.


************** Exception Text **************
Microsoft.VisualStudio.Tools.Applications.Runtime.CannotCreateCustomizationDomainException: Customization could not be loaded because the application domain could not be created. ---> System.IO.FileLoadException: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(String assemblyName, String typeName)
at System.AppDomain.CreateInstance(String assemblyName, String typeName)
at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName)
at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName)
at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.CreateCustomizationDomainInternal(String documentFullLocation, String documentName, String assemblyLocation, Boolean showUIDuringDeployment, IntPtr hostServiceProvider, IntPtr& executor)
--- End of inner exception stack trace ---

How can I remove this exception?

Thanks,
Nikhil
Posted 03 Feb, 2010 06:03:23 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hi Nikhil,

I don't know why that exception occurs. I think the best way is to create a dummy add-in and gradually add to it the functionality of your actual add-in.

What VSTO version do you use? Do you develop your add-in for Office 2003, 2007, or both?


Andrei Smolin
Add-in Express Team Leader
Posted 05 Feb, 2010 03:36:16 Top