I am trying to import small DLL from Vulcan (Visual Studio) and to test X# using XIDE 1.09.
I can't add reference system.net.mail in order to use SMTP functions with authentcation. Why is this namespace (reference) missing in the list offered by XIDE ?
/* ----- a part of imported code
// OK
#using System.Windows.Forms
// OK
#using System.Runtime.InteropServices
// OK
#USING System.Net
// not in the list --- error
#USING System.Net.Mail
BEGIN NAMESPACE SMTP_X#_Lib
*/
---
TIA, Andrej
system.net.mail reference
system.net.mail reference
Andrej,
just made a new X# basic app.
"Using System.Net" is suggested by intellisense, as ist System.Net.Mail
Albeit, the latter took some time to "appear" - but i simply typed and compiled without any error.
Karl
just made a new X# basic app.
"Using System.Net" is suggested by intellisense, as ist System.Net.Mail
Albeit, the latter took some time to "appear" - but i simply typed and compiled without any error.
Karl
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
system.net.mail reference
Hi Andrej,
References and namespaces are completely different things, unfortunately MS has messed up bigtime in this area and made it needlessly complicated, but in short:
- Namespace is the part of a class name that appears before the last dot (if any). So, in class name "System.Windows.Forms.CheckBox", the part "System.Windows.Forms" is called the "namespace". Similarly, in System.Collections.ArrayList, the "System.Collections" part is the namespace. Namespaces are nothing concrete, they are just a naming convention, a way to logically group together many classes with similar scope. Also a class can have no namespace at all (like all classes did in VO).
- References are practically just simple (.Net) dll files (usually called "Assemblies" in .Net) and you choose which ones to use in your apps with the Add References option. Typical such system dll files include "System.dll", "System.Windows.Forms.dll", "mscorlib.dll" (contains all the most important classes like simple data types etc) etc.
The names of the system dlls probably sound like they imply that there's a 1:1 relevance to the namespace of the classes they contain, but unfortunately this is far from true. So for example, System.Windows.Forms.dll indeed contains a class named "System.Windows.Forms.CheckBox", and System.drawing.dll contains "System.Drawing.Point" which makes sense, but System.Windows.Forms.dll also contains class "System.Drawing.BitmapSelectot". And System.Drawing.dll contains a class named "System.Windows.Forms.DpiHelper"! I know it looks very weird, it just needs some getting used to.
In your case, you need to use some classes like "System.Net.Mail.MailMessage", "System.Net.Mail.Attachment" etc. If you search about those classes in msdn:
https://msdn.microsoft.com/en-us/librar ... .110).aspx
you will see in the top of the page:
Attachment Class: Represents an attachment to an e-mail.
Namespace: System.Net.Mail
Assembly: System (in System.dll)
which tells us that this class is defined inside the assembly (dll) System.dll. So, first thing you need to make sure is your app has a reference to this dll, you can open the Application Properties, References page and add this (from the "GAC" list) if it is missing. Alternatively you can press the "Select from template" button and select "Standard Full Framework" to automatically add some commonly used references.
After doing that, now you can use "USING System.Net.Mail" in your code. This tells the compiler to go through all the dlls in the references list and search for classes with names that have this namespace. If no such class is found, then an error is reported (as in your case earlier, because there was no reference to System.dll, so no class was found with that namespace), otherwise the compiler let's you use the "short" names of those classes, for example simply "LOCAL oMessage AS MailMessage" instead of "LOCAL oMessage AS System.Windows.Forms.MailMessage".
Well, this turned out much longer than the "in short" I said in the beginning Hope I helped making things clearer and not even more complicated!
Chris
References and namespaces are completely different things, unfortunately MS has messed up bigtime in this area and made it needlessly complicated, but in short:
- Namespace is the part of a class name that appears before the last dot (if any). So, in class name "System.Windows.Forms.CheckBox", the part "System.Windows.Forms" is called the "namespace". Similarly, in System.Collections.ArrayList, the "System.Collections" part is the namespace. Namespaces are nothing concrete, they are just a naming convention, a way to logically group together many classes with similar scope. Also a class can have no namespace at all (like all classes did in VO).
- References are practically just simple (.Net) dll files (usually called "Assemblies" in .Net) and you choose which ones to use in your apps with the Add References option. Typical such system dll files include "System.dll", "System.Windows.Forms.dll", "mscorlib.dll" (contains all the most important classes like simple data types etc) etc.
The names of the system dlls probably sound like they imply that there's a 1:1 relevance to the namespace of the classes they contain, but unfortunately this is far from true. So for example, System.Windows.Forms.dll indeed contains a class named "System.Windows.Forms.CheckBox", and System.drawing.dll contains "System.Drawing.Point" which makes sense, but System.Windows.Forms.dll also contains class "System.Drawing.BitmapSelectot". And System.Drawing.dll contains a class named "System.Windows.Forms.DpiHelper"! I know it looks very weird, it just needs some getting used to.
In your case, you need to use some classes like "System.Net.Mail.MailMessage", "System.Net.Mail.Attachment" etc. If you search about those classes in msdn:
https://msdn.microsoft.com/en-us/librar ... .110).aspx
you will see in the top of the page:
Attachment Class: Represents an attachment to an e-mail.
Namespace: System.Net.Mail
Assembly: System (in System.dll)
which tells us that this class is defined inside the assembly (dll) System.dll. So, first thing you need to make sure is your app has a reference to this dll, you can open the Application Properties, References page and add this (from the "GAC" list) if it is missing. Alternatively you can press the "Select from template" button and select "Standard Full Framework" to automatically add some commonly used references.
After doing that, now you can use "USING System.Net.Mail" in your code. This tells the compiler to go through all the dlls in the references list and search for classes with names that have this namespace. If no such class is found, then an error is reported (as in your case earlier, because there was no reference to System.dll, so no class was found with that namespace), otherwise the compiler let's you use the "short" names of those classes, for example simply "LOCAL oMessage AS MailMessage" instead of "LOCAL oMessage AS System.Windows.Forms.MailMessage".
Well, this turned out much longer than the "in short" I said in the beginning Hope I helped making things clearer and not even more complicated!
Chris
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
-
- Posts: 31
- Joined: Mon Nov 02, 2015 2:08 pm
system.net.mail reference
Thanks Chris and Karl.
Using "System" regerence solves the problem.
My intention with this message was also to clarify why in the GAC list "system.net.mail " reference is missing.
See attachment.
Best regards, Andrej
Using "System" regerence solves the problem.
My intention with this message was also to clarify why in the GAC list "system.net.mail " reference is missing.
See attachment.
Best regards, Andrej
system.net.mail reference
Hi Andrej,
There does not exist a references "System.Net.Mail" because there does not exist a file System.Net.Mail.dll. Most of the email related code is located inside System.dll (not even in System.Net.dll, I think you don't need this reference at all), this is why you needed to add the reference to System.
Chris
There does not exist a references "System.Net.Mail" because there does not exist a file System.Net.Mail.dll. Most of the email related code is located inside System.dll (not even in System.Net.dll, I think you don't need this reference at all), this is why you needed to add the reference to System.
Chris
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
system.net.mail reference
Hi Andrej,
please let me add something: when programming, you will need a Microsoft reference anyway, and look at the "Assembly" information.
Only with this information you have a guarantee to add the right reference DLL.
For the correct namespace in XIDE: a right click on the name of the class should open the context menu. Select "Search for type named xx in namespaces" and in most cases XIDE will find the correct namespace and add it on the of your file.
Most of the time this is faster than typing a long using like "using System.Collections.Generic".
Wolfgang
please let me add something: when programming, you will need a Microsoft reference anyway, and look at the "Assembly" information.
Only with this information you have a guarantee to add the right reference DLL.
For the correct namespace in XIDE: a right click on the name of the class should open the context menu. Select "Search for type named xx in namespaces" and in most cases XIDE will find the correct namespace and add it on the of your file.
Most of the time this is faster than typing a long using like "using System.Collections.Generic".
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it