?
Solved

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

Posted on 2006-07-13
10
Medium Priority
?
773 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
The viewer will learn how to count occurrences of each item in an array.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

777 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