Solved

EXTREMELY URGENT - web.config problem/errors with "add namespace" command.

Posted on 2006-07-13
10
767 Views
Last Modified: 2013-11-19
I'm trying to add the System.Net.Mail namespace to my C#.NET webpage so that I can send emails from the code. But I get these errors...

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0234: The type or namespace name 'Mail' does not exist in the class or namespace 'System.Net' (are you missing an assembly reference?)

Source Error:

Line 9:  <%@ Import Namespace = "System.Net.Mail" %>

 

Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Child nodes are not allowed.

Source Error:

Line 8:  
Line 9:      <pages>
Line 10:       <namespaces>
Line 11:         <add namespace="System.Net.Mail" />
Line 12:       </namespaces>
 


The web.config file reads as this...

<?xml version="1.0" encoding="utf-8" ?>

<configuration>  

  <system.web>
    <compilation defaultLanguage="c#" debug="true" />
    <customErrors mode="Off"/>

    <namespaces>
      <add namespace="System.Net.Mail" />
    </namespaces>

  </system.web>

  <appSettings>
      ***HIDDEN TO PROTECT APPLICATION SECURITY***
  </appSettings>

</configuration>
0
Comment
Question by:davepusey
  • 5
  • 4
10 Comments
 
LVL 12

Expert Comment

by:deanvanrooyen
ID: 17102902
try right click the project, go to properties pages >  references and add it in there....

then you can <%@ Import Namespace = "System.Net.Mail" %>
0
 
LVL 12

Expert Comment

by:deanvanrooyen
ID: 17102945
or in you code dont even import the namespace just do this in the inline code

System.Net.Mail.Mailmessage m = new ....


http://www.developer.com/net/asp/article.php/3096831
0
 
LVL 12

Expert Comment

by:deanvanrooyen
ID: 17102998
sorry ignore my

try right click the project, go to properties pages >  references and add it in there....

then you can <%@ Import Namespace = "System.Net.Mail" %>

just use the article....

take then     <namespaces>
      <add namespace="System.Net.Mail" />
    </namespaces>

out of the web.config  and just <%@ Import Namespace="System" %>  then use System.Net.Mail.Mailmessage m = new .... in you code should work....
sorry I just use code behind not inline... if it doesnt let us kow
0
 
LVL 4

Expert Comment

by:DarkXiphoid
ID: 17103053
Is it a .dll that contains the system.net.mail namespace?

If so, you have to put it in your bin directory before you can use it.

If it is a namespace that is within the .net framework package, adding:

using System.Net.Mail;

to your codebehind page should do the trick.
0
 
LVL 12

Expert Comment

by:deanvanrooyen
ID: 17103118
System.Net.Mail is a generic .net namespace holds classes for smtp stuff

ps it is only in .net 2.0 !  -  davepusey   are you using 2.0?

http://msdn2.microsoft.com/en-us/library/system.net.mail.aspx
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Author Comment

by:davepusey
ID: 17103484
Cant only be in .NET 2 cos i have 1.1 winforms app that use it.

and i cant do codebehind or project menu ideas cos dreamweaver only does inline.

will try deanvanrooyen  #2 and #3 posts in a moment. will let u know.
0
 
LVL 2

Author Comment

by:davepusey
ID: 17103648
>> take out of the web.config  and then use System.Net.Mail.Mailmessage m = new .... in you code

ok done that now i get


Compiler Error Message: CS0234: The type or namespace name 'Mail' does not exist in the class or namespace 'System.Net' (are you missing an assembly reference?)

Source Error:

Line 10: System.Net.Mail.MailMessage m = new System.Net.Mail.MailMessage();
 
0
 
LVL 2

Author Comment

by:davepusey
ID: 17103656
Just added <%@ Import Namespace="System" %> too, still same error.
0
 
LVL 12

Accepted Solution

by:
deanvanrooyen earned 500 total points
ID: 17103771
the doc says
.NET Framework Class Library  
System.Net.Mail Namespace  
Note: This namespace is new in the .NET Framework version 2.0.
http://msdn2.microsoft.com/en-us/library/system.net.mail.aspx

maybe you have downloaded and installed 2.0? for the winforms apps - if you check the winform app code does it have a reference to this assembly?
do you have this on the machines in question - C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
therefore you would have to add a refrerence to the assmbely in the web.config some like


I believe 1.1 uses System.Web.Mail try import this namespace see if there is an error

I have just tested this inline and it runs no issue.
<%@ Import Namespace = "System.Net.Mail" %>

not sure what else to suggest

0
 
LVL 2

Author Comment

by:davepusey
ID: 17106479
>> I believe 1.1 uses System.Web.Mail try import this namespace see if there is an error

Yep that got it working. Cheers folks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now