Solved

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

Posted on 2006-07-13
10
772 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
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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 article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
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…

705 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