Last post Apr 18, 2008 04:48 PM by nloyer
Apr 16, 2008 03:36 PM|nloyer|LINK
What are the exact steps needed to install a control and use it in your project? I am having problem after problem with this, and assume it's something stupid that I'm not doing. So pretend that I know absolutely nothing and detail every teensy weensy
Apr 16, 2008 04:16 PM|ps2goat|LINK
There are a few different ways.
1. Build the assembly. Add it as a reference in the project you want to use it in. Open your ToolBox window, right-click in some dead space (i.e., not on a control or icon), and click on 'Choose Items'. (I'm assuming you are using a .NET assembly here.)
The .NET Framework Components tab should be open. I would click on 'Namespace' to sort by namespace, then search for the namespace of the assembly you are using. From here, check the checkbox next to the controls you want to add to the toolbox.
2. More complicated, possibly more annoying for testing purposes (if you plan on rebuilding your control quite often): You'll need to generate a strong name key for your assembly, which will allow you to install it into the GAC (Global Assembly Cache).
This is similar to registering a COM component, which will allow the assembly's controls to be available in the toolbox for any project, not just the one referencing the dll. (Additionally, dragging the control from the toolbox and onto a page in a new project
should automatically add the appropriate reference to the dll.)
For the GAC option, see this link for creating an assembly with a strong name:
http://msdn.microsoft.com/en-us/library/ms813014.aspx. See this link for installing an assembly with a strong name into the GAC:
Apr 16, 2008 05:16 PM|nloyer|LINK
Thanks for your post, I'm really serious about detail here, so let me ask more questions:
1. Build the assembly. - How? What files, what buttons? I have a zip file with a dll, and there is source in all the folders somewhere, but I don't know what to open or anything, I need really basic directions. I know code, I don't know any .NET processes.
2. Add it as a reference in the project you want to use it in. - Again, how?
Open your ToolBox window, right-click in some dead space (i.e., not on a control or icon), and click on 'Choose Items'. (I'm assuming you are using a .NET assembly here.) The .NET Framework Components tab should be open. I would click on 'Namespace' to
sort by namespace, then search for the namespace of the assembly you are using. From here, check the checkbox next to the controls you want to add to the toolbox.\
Okay, they are already referenced here, but the location is on my local machine. My application files are all on the development web server. I tried choosing the dll from the development web server, but got this error: "Request for the permission of type
'System.Web.AspNetHostingPermission, Version=126.96.36.199, Culture=neutral, PublicKeyToken=blah' failed."
Apr 18, 2008 01:36 PM|ps2goat|LINK
If you have the DLL, then the project may be 'built' already. 'Building' means compiling, where the IDE (Visual Studio) compiles your high level code into an intermediate code. (.NET is closer to Java than C++, it is converted to a type of code that must
still be interpreted at run time, whereas C++ would run as machine-level code of 0s and 1s. This is why people must have the .Net Framework version you programmed in in order to run your code.)
To build a project, you must have the project open in the IDE. Then, Click on the 'Build' menu at the top of the IDE, and choose 'Build project' or 'Build Solution'. This will change according to the type of project you have open.
The build process will compile the project for you. If this was created as a Windows Control Library, then it should automatically compile as a DLL. By default, it will compile under the *project name*\obj\*build type*\, where *project name* is the name
of the project folder (should be where you opened it from), and *build type* is the build type. If you look toward the top of the screen, near the menu bar, there is a drop-down list. This will usually contain 'Debug' or 'Release'. 'Debug' means that when
the project is built, special symbols are left in the DLL so that it can be debugged or stepped-through. This also creates a larger file. 'Release' means that the project is built as streamlined as possible-- no special symbols, and optimized, providing
a leaner DLL.
To add a DLL as a reference, open the project that needs to use this control (or create a new project). Open the 'Solution Explorer' tab (should be open to the left side in the IDE; if not, click the magnifying glass icon next to the Debug drop-down list
to open it). Right-click the Project name of what you wish to add this control to, and click 'Add Reference'. This will bring up the box I mentioned in my first post.
As for your issue with development/production, the issue is probably too complicated to get into right now. It would be more efficient and secure to just copy the DLL from the production server to the local machine and reference it there. If this was in
the GAC of the production server, just copy it into the local machine's GAC. Open Windows Explorer (or a normal folder) and change the address line to "C:\Windows\assembly". (change the drive letter as necessary) This will open the GAC. Now to install
the DLL, simply drag the copy of the DLL into this folder; the DLL will be automatically installed. It should then show up in as described in my first post, under .NET Framework tab.
If the DLL is not in the GAC on production, you can just add the reference to the local DLL. When you move your project to the production server, the DLL will have to be copied over with it, and placed in a similar directory structure. (Usually, DLLs are
in *app directory*\bin\ folder)
Apr 18, 2008 04:48 PM|nloyer|LINK
Great answer. Thank you!