Hallo Frank, wenn deine Klasse FormMailer sich im gleichen Projekt befindet wie deine Page-Klasse, dann m�sste es wie folgt funktionieren:
<%@ Import Namespace = "Assemblyname bzw. meist Projektname.Reissner.WebTools" %> wenn nicht, dann fehlt dir im aktuellen Projekt die Reference zur der Assembly, in der sich deine FormMailer-Klasse befindet. Also m�sstest du zuerst ein Verweis auf diese Assembly in deinem Projekt erstellen und dann m�sste es mit den Namespaces funktionieren: <%@ Import Namespace = "Reissner.WebTools" %> ich hoffe, ich konnte dir helfen... Gr�sse Andreas -----Urspr�ngliche Nachricht----- Von: Frank Rei�ner [mailto:[EMAIL PROTECTED]] Gesendet: Donnerstag, 18. Juli 2002 14:15 An: aspDEdotnet Betreff: [aspdedotnet] Fehler beim Einbinden eines eigenen Namespaces Bin grad dabei mir eine Klasse zu basteln (in VB) die mir ein aus einem x-beliebigen Web-Formular eine Mail erstellt da da ja eine wiederverwendbare Komponente w�re dachte ich mir f�ngst du mal an mit Namespaces rumzuprobieren. Leider bekomme ich immer eine Fehlermeldung wenn ich meinen Namespace aufrufen will. Ich bin so verr�ckt und poste mal den kompletten Code nehmt es mir nich �bel aber ich hab keine Idee mehr was ich machen k�nnte Das ist der Code meiner Klasse: Imports System.Collections.Specialized Imports System.Xml Imports System.Web Imports System.Web.Mail Namespace Reissner.WebTools Public Class FormMailer ' Settings ' Private _strMailFrom As String Private _strMailTo As String Private _strMailSubject As String Private _blnIsAlphabeticSort As Boolean Private _strMailText As String Private _blnIsSend As Boolean = False ' Values ' Private _FormValueCollection As NameValueCollection ' Constructor 1 ' Public Sub New(ByVal nvcForm As NameValueCollection) _FormValueCollection = nvcForm End Sub ' Constructor2 ' Public Sub New(ByVal nvcForm As NameValueCollection, ByVal XmlFile As String) _strMailFrom = GetSettingFromXml(XmlFile, "MailFrom") _strMailTo = GetSettingFromXml(XmlFile, "MailTo") _strMailSubject = GetSettingFromXml(XmlFile, "MailSubject") _blnIsAlphabeticSort = GetSettingFromXml(XmlFile, "IsAlphaBetic") _FormValueCollection = nvcForm End Sub ' Public Properties ' Public Property IsAlphabeticSort() As Boolean Get Return _blnIsAlphabeticSort End Get Set(ByVal Value As Boolean) _blnIsAlphabeticSort = Value End Set End Property Public Property MailTo() As String Get Return _strMailTo End Get Set(ByVal Value As String) _strMailTo = Value End Set End Property Public Property MailFrom() As String Get Return _strMailFrom End Get Set(ByVal Value As String) _strMailFrom = Value End Set End Property Public Property MailSubject() As String Get Return _strMailSubject End Get Set(ByVal Value As String) _strMailSubject = Value End Set End Property ' Protected (Private) Methods ' ' Function: Private Function GetSettingFromXml(ByVal XmlFile As String, ByVal Setting As String) As String ' ' Selects the settings from a XmlFile ' Expected structure: ' ' <FormMailer> ' <MailTo></MailTo> ' <MailFrom></MailFrom> ' <MailSubject></MailSubject> ' <SortAlphabetic></SortAlphabetic> '</FormMailer> ' Private Function GetSettingFromXml(ByVal XmlFile As String, ByVal Setting As String) As String Dim configFile As New XmlDocument() Dim asSettings(3) As String Dim ThisSetting As XmlNodeList ThisSetting = configFile.GetElementsByTagName("MailTo") asSettings(0) = ThisSetting.Item(0).InnerText ThisSetting = configFile.GetElementsByTagName("MailFrom") asSettings(1) = ThisSetting.Item(0).InnerText ThisSetting = configFile.GetElementsByTagName("MailSubject") asSettings(2) = ThisSetting.Item(0).InnerText ThisSetting = configFile.GetElementsByTagName("SortAlphabetic") asSettings(3) = ThisSetting.Item(0).InnerText Return asSettings(Setting) End Function ' Public Methods ' ' Function: Public Sub CreateMailFromForm() ' ' Parse the form and create the mailtext Public Sub CreateMailFromForm() Dim intCounter As Integer Dim asValues() As String = _FormValueCollection.AllKeys If _blnIsAlphabeticSort = True Then Array.Sort(asValues) End If Dim dtSetTime As DateTime = Now() _strMailText &= "FormularEintrag vom " & dtSetTime.ToString("F") _strMailText &= "" & vbCrLf & vbCrLf & "--------------------------------------------------------------------------- -----------------" For intCounter = 0 To asValues.GetUpperBound(0) _strMailText &= "" & vbCrLf & vbCrLf & vbTab & asValues(intCounter) & ": " & _FormValueCollection.Item(asValues(intCounter)) Next intCounter _strMailText &= "" & vbCrLf & vbCrLf & "--------------------------------------------------------------------------- -----------------" End Sub ' Function: Public Sub SendMail() ' Sends the Mail Public Sub SendMail() SmtpMail.Send(_strMailFrom, _strMailTo, _strMailSubject, _strMailText) End Sub End Class End Namespace Das der der nutzenden Aspx-Page: <%@ Page Language="vb" debug="true" %> <%@ Import Namespace = "Reissner.WebTools" %> <% Dim RequestForm As NameValueCollection= Request.Form Dim XmlFile As String = "config.xml" Dim FormMailer As FormMailer = New FormMailer(RequestForm, ServerMapPath(XmlFile)) FormMailer.CreateMailFromForm() FormMailer.SendMail() Response.Write("Versuch!!") %> Und das ist leider die Fehlermeldung: Server Error in '/aspdotnet/Sniplets/TestFormMailerDll' Application. 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: BC30182: Type expected. Source Error: Line 10: Dim XmlFile As String = "config.xml" Line 11: Line 12: Dim FormMailer As FormMailer = New FormMailer(RequestForm, ServerMapPath(XmlFile)) Line 13: Line 14: FormMailer.CreateMailFromForm() Source File: D:\iis5_documents_storage\htdocs\aspdotnet\Sniplets\TestFormMailerDll\sendMa il.aspx Line: 12 Show Detailed Compiler Output: C:\WINNT\system32> "c:\winnt\microsoft.net\framework\v1.0.3705\vbc.exe" /t:library /utf8output /R:"c:\winnt\assembly\gac\system.web\1.0.3300.0__b03f5f7f11d50a3a\system.web .dll" /R:"c:\winnt\assembly\gac\system\1.0.3300.0__b77a5c561934e089\system.dll" /R:"c:\winnt\assembly\gac\system.data\1.0.3300.0__b77a5c561934e089\system.da ta.dll" /R:"c:\winnt\assembly\gac\system.web.services\1.0.3300.0__b03f5f7f11d50a3a\s ystem.web.services.dll" /R:"c:\winnt\assembly\gac\system.drawing\1.0.3300.0__b03f5f7f11d50a3a\system .drawing.dll" /R:"c:\winnt\assembly\gac\system.enterpriseservices\1.0.3300.0__b03f5f7f11d5 0a3a\system.enterpriseservices.dll" /R:"c:\winnt\assembly\gac\system.web.mobile\1.0.3300.0__b03f5f7f11d50a3a\sys tem.web.mobile.dll" /R:"c:\winnt\microsoft.net\framework\v1.0.3705\temporary asp.net files\aspdotnet_sniplets_testformmailerdll\e404c2b3\64d29847\assembly\dl\92f dcbd7\a0cda348_5726c201\imageinfo.dll" /R:"c:\winnt\microsoft.net\framework\v1.0.3705\temporary asp.net files\aspdotnet_sniplets_testformmailerdll\e404c2b3\64d29847\assembly\dl\0bf 3fcc0\4a397662_522ec201\formmailer.dll" /R:"c:\winnt\assembly\gac\system.xml\1.0.3300.0__b77a5c561934e089\system.xml .dll" /R:"c:\winnt\assembly\gac\analogclock-entwicklung\1.0.0.0__040c29fc9895f6c4\ analogclock-entwicklung.dll" /out:"C:\WINNT\Microsoft.NET\Framework\v1.0.3705\Temporary ASP.NET Files\aspdotnet_sniplets_testformmailerdll\e404c2b3\64d29847\0yw8ra_x.dll" /D:DEBUG=1 /debug+ "C:\WINNT\Microsoft.NET\Framework\v1.0.3705\Temporary ASP.NET Files\aspdotnet_sniplets_testformmailerdll\e404c2b3\64d29847\0yw8ra_x.0.vb" Microsoft (R) Visual Basic .NET Compiler version 7.00.9466 for Microsoft (R) .NET Framework version 1.00.3705 Copyright (C) Microsoft Corporation 1987-2001. All rights reserved. C:\WINNT\Microsoft.NET\Framework\v1.0.3705\Temporary ASP.NET Files\aspdotnet_sniplets_testformmailerdll\e404c2b3\64d29847\0yw8ra_x.0.vb(1 5) : error BC30466: Namespace or type 'WebTools' for the Imports 'Reissner.WebTools' cannot be found. Imports Reissner.WebTools ~~~~~~~~~~~~~~~~~ D:\iis5_documents_storage\htdocs\aspdotnet\Sniplets\TestFormMailerDll\sendMa il.aspx(12) : error BC30182: Type expected. Dim FormMailer As FormMailer = New FormMailer(RequestForm, ServerMapPath(XmlFile)) ~~~~~~~~~~ Danke f�r alles was mir hilft Mit freundlichen Gr�ssen Frank Reissner | [aspdedotnet] als [EMAIL PROTECTED] subscribed | http://www.dotnetgerman.com/archiv/aspdedotnet/ = Listenarchiv | Sie k�nnen sich unter folgender URL an- und abmelden: | http://www.dotnetgerman.com/listen/aspDEdotnet.asp | [aspdedotnet] als [email protected] subscribed | http://www.dotnetgerman.com/archiv/aspdedotnet/ = Listenarchiv | Sie k�nnen sich unter folgender URL an- und abmelden: | http://www.dotnetgerman.com/listen/aspDEdotnet.asp
