Visual Studio uses different sets of the PIAs on the development computer. These different sets of assemblies are in the following locations:. These copies of the assemblies are used when you write code and build projects.
Visual Studio installs these assemblies automatically. These copies of the assemblies are used during some development tasks, such as when you run or debug projects. Visual Studio does not install and register these assemblies; you must do this yourself. When you install Visual Studio, the PIAs are automatically installed to a location in the file system, outside of the global assembly cache.
When you create a new project, Visual Studio automatically adds references to these copies of the PIAs to your project. Visual Studio uses these copies of the PIAs, instead of the assemblies in the global assembly cache, to resolve type references when you develop and build your project. These copies of the PIAs help Visual Studio avoid several development issues that can occur when different versions of the PIAs are registered in the global assembly cache.
Starting with Visual Studio , these copies of the PIAs are installed to following shared locations on the development computer:. To perform certain development tasks, the PIAs must be installed and registered in the global assembly cache on the development computer.
Typically, the PIAs are installed automatically when you install Office on the development computer. For more information, see Configure a computer to develop Office solutions. For more information, see Design and create Office solutions. Every Office project template in Visual Studio is designed to work with a single Microsoft Office application. To use features in multiple Microsoft Office applications, or to use features in an application or component that does not have a project in Visual Studio, you must add a reference to the required PIAs.
These versions of the assemblies appear on the Framework tab of the Reference Manager dialog box. For more information, see How to: Target Office applications through primary interop assemblies. If you have installed and registered the PIAs in the global assembly cache, these versions of the assemblies appear on the COM tab of the Reference Manager dialog box. You should avoid adding references to these versions of the assemblies, because there are some development issues that can occur when you use them.
For example, if you have registered different versions of the PIAs in the global assembly cache, your project will automatically bind to the version of the assembly that was registered last—even if you specify a different version of the assembly on the COM tab of the Reference Manager dialog box. Some assemblies are added to a project automatically when an assembly that references them is added. For example, references to the Office. The following table lists the primary interop assemblies that are available for Office , Office and Office When you install and register the Office PIAs in the global assembly cache either with Office or by installing the redistributable package for the PIAs , the binding redirect assemblies are also installed only in the global assembly cache.
These assemblies help make sure that the correct version of the primary interop assemblies is loaded at run time. For example, when a solution that references a Office assembly runs on a computer that has the Office version of the same primary interop assembly, the binding redirect assembly instructs the.
NET Framework runtime to load the Office version of the primary interop assembly. Note Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. To create a new console application Start Visual Studio.
In the Templates pane, click Console Application. Type a name for your project in the Name field. Click OK. The new project appears in Solution Explorer. To add references In Solution Explorer , right-click your project's name and then click Add Reference. To add necessary using directives In Solution Explorer , right-click the Program. Add the following using directives to the top of the code file: To create a list of bank accounts Paste the following class definition into Program.
To declare a method that exports account information to Excel Add the following method to the Program class to set up an Excel worksheet. To run the project Add the following line at the end of Main.
An Excel worksheet appears that contains the data from the two accounts. To add a Word document To illustrate additional ways in which C 4, and later versions, enhances Office programming, the following code opens a Word application and creates an icon that links to the Excel worksheet. Add the following statement at the end of Main.
If you cannot see the Properties window, press F4. To add additional formatting to the table Replace the two calls to AutoFit in DisplayInExcel with the following statement. Other formats are listed in the XlRangeAutoFormat enumeration. Example The following code shows the complete example. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Reference Microsoft. Asked 7 years, 8 months ago. Active 7 years, 7 months ago.
Viewed 3k times. DBEngine ; this line gave me an error: System. Community Bot 1 1 1 silver badge. Add a comment. Active Oldest Votes. Sign up or log in Sign up using Google.
That is accomplished by right-clicking the Solution in the Solution Explorer pane and choosing Add Reference :. There is another reference that should be added to the project.
DLL by clicking the Browse tab, navigating to the appropriate folder, and then double-clicking the file. Once the reference is added you can access it using the namespace or you can use an alias to import the namespace. For example, if you want to reference the Microsoft. I decided to have a series of TreeViews to represent the tables, queries, and relationships.
Once you have the form available you can add an OnClick event on a button. In this project I want to find out everything I can about the database, so we start by gathering the database properties into a StringBuilder and displaying it in a textbox.
The next step is that I loop through the items in each collection, obtaining the desired information. In the Data Viewer section I had to be a little more creative. I built a data table using the fields represented and used the New Row function to populate the data table. Once the table was fully populated I set the datasource of a DataGridView :.
Object , ByVal e As System. EventArgs Handles. Dim dbEngine As New Microsoft. Dim db As Microsoft. Dim RS As Microsoft. Show "qqq". Fields "Functie". If Not RS. End Sub. Let me dig through my code stashes to see if I can find it. If I can't then I'll re-create some of it and post.
Tim, I too am interested in the code you have described in this article. I realize it's been 17 months since this article was published, but maybe hopefully you still have access to that soure code and are willing to post it here? NET to create an Access database interrogation tool. Related Articles. Learn how to build a multithreading. Popular Articles. Rolling up multiple rows into a single row and column for SQL Server data.
How to tell what SQL Server versions you are running. Resolving could not open a connection to SQL Server errors.
Ways to compare and find differences for SQL Server tables and data.
0コメント