Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

FileNotFoundException error being thrown in Visual Studio 2010 extensibility projects with references to class libraries.

$
0
0

In VS2008, if you wanted to componentize logic in a class library project and add a reference to that project to a Visual Studio Add-in project, doing so was seamless and worked as expected.   Now, in VS2010, a FileNotFoundException is thrown.

This is the short test to demonstrate the issue:

1.    As a simple test, create a new C# solution with an initial project of type Extensibility/Visual Studio Add-in. (The default “MyAddin” add-in name is acceptable for this test.)

a.    Apply these settings in the Visual Studio Add-in Wizard

                                         i.    Create an Add-in using Visual C# then select Next.

                                        ii.    Check Microsoft Visual Studio 2010 then select Next.

                                       iii.    Leave the default add-in name then select Next.

                                       iv.    Check the “Yes, create ‘Tools’ menu item” option then select Next.

                                        v.    Ignore the “Yes, I would like my add-in to offer ‘About’ box information then select Next.

                                       vi.    Select Finish

2.    Add a new project to that solution of type Visual C# Class Library. (The default ClassLibrary1 name is acceptable for this test.)

3.    Add a public method to the Class1 class that returns a value. My sample method was

namespace ClassLibrary1 {
    public class Class1 {
        public string GetSomething(){return "did something";}
    }
}

4.    Add a reference to the ClassLibrary1 project to the MyAddin1 add-in project

5.    In the Connect.cs class in the add-in project, add logic that tests the method in the Class1 class in referenced ClassLibrary1 project:

        public void TestReferenceAssembly() {
            try {
                Class1 c1 = new Class1();
                var res = c1.GetSomething();
            } catch (Exception ex) {
#if(DEBUG)
                Console.WriteLine(ex.ToString());
#endif
            }
        }

6.    Invoke the newTestReferenceAssembly method from the public void Exec method.

public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) {
            handled = false;
            if (executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault) {
                if (commandName == "MyAddin1.Connect.MyAddin1")
                {
                    TestReferenceAssembly();
                    handled = true;
                    return;
                }
            }
        }

7.    Put a breakpoint on the TestReferenceAssembly method

8.    Press F5 to run the project.

9.    In the new Visual Studio instance that loads, select the new Add-in from the Tools menu

 

As you will see, a FileNotFoundException is being thrown. Expanding the bin/debug folders reveals that the referenced project’s assembly is properly being copied.  Does anyone know what could possibly be causing this problem?

 

 


Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>