Solved

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

Posted on 2006-07-13
10
763 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

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…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

757 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

16 Experts available now in Live!

Get 1:1 Help Now