Solved

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

Posted on 2006-07-13
10
770 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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
 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
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 learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

790 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