|
Subject:
|
need to add a reference to System.Net.Mail
|
|
Posted By:
|
erik
|
Post Date:
|
8/30/2006 8:51:21 AM
|
Hi,
In Chapter 3 (page 104) the code for the txtSubmit_Click() event is displayed. Marco uses a MailMessage class, which is included in the System.Net.Mail namespace.
I have added "using System.Net.Mail;" to the top of the file where the event is implemented, but it seems that it doesn't recognize the namespace. I tried adding a reference to it (menu: WebSite->Add reference), but System.Net.Mail isn't listed in the Dialog box (under the .NET tab). Is it just my system, or isn't System.Net registered by default?
In any case, does anyone know how I can add a reference to this namespace, or even make it appear in the Add reference dialog box? I have read somewhere on the net that I need to add registry keys if I want to make my home-made namespaces appear on the Add reference namespace list, but I don't know if this applies to me as well. After all, the System.Net.Mail namespace is a part of the System.dll file, which is referenced. I don't get it.
Could anyone nudge me in the right direction?
-------- Wisdom on the internet? How rare!
|
|
Reply By:
|
erik
|
Reply Date:
|
8/31/2006 4:02:47 AM
|
I solved this problem. However, I'm not entirely certain of what caused the problem to be fixed. I read a bit of the GAC (Global Assembly Cache), and thought maybe I had to re-register the System.dll assembly, since it seemed that some assemblies within it wasn't available from within the Add Reference dialog box in Visual Studio. I ran the following command from the Visual Studio command line:
gacutil -if [assemblyPath]
I restarted my PC, but I still couldn't add the reference. Wasn't on the list. I then tried to build the web site, and resolved a missing namespace (had to add "using System.Web.Configuration" to the file App_Code\Globals.cs). Then all of a sudden, IntelliSense displayed System.Net related assemblies, where it before had shown none.
I believe it was the gacutil assembly registration of the System.dll file that did the trick, but it seems that Visual Studio needed me to execute the "Build website" command before it noticed that System.dll had been re-registered. Well, at least, that is my theory. Anyway, problem is solved :)
I hope this will be able to help other people who may experience the same problem.
-------- Wisdom on the internet? How rare!
|
|
Reply By:
|
ryandoah
|
Reply Date:
|
8/31/2006 10:34:26 AM
|
Yeah, I had this happen to. It self corrected after a while, so I don't know what the problem was. When I originally tried to enter the namespace I put it at the bottom of the list of declared namespaces, when it corrected, I was trying to put it somewhere in the middle by alphabetized order. I have no idea what caused it.
As far as sending the mail. I put the sendMail function in the helpers class, so that I can use it in other places in the website.
|