Project Items - What's the purpose?

  • Thread starter Thread starter copyco
  • Start date Start date
C

copyco

Can anyone tell me what the purpose is to adding items such as a
VBScript file or HTML document to your VB.NET project? Once you have
these things added, how to you access them and use them in your code?
 
* copyco said:
Can anyone tell me what the purpose is to adding items such as a
VBScript file or HTML document to your VB.NET project? Once you have
these things added, how to you access them and use them in your code?

What exactly do you want to do with the files?
 
copyco,
Can anyone tell me what the purpose is to adding items such as a
VBScript file or HTML document to your VB.NET project?
These files are commonly used in ASP.NET (web projects).

I will use an HTML document in Windows Forms projects to contain
documentation and/or readme files.

Having them in a Windows Forms project is also useful if your Windows Forms
project relies on the Web Browser control for its primary interface...

I'm sure there are other uses for them (read as "think out side the box").
Once you have
these things added, how to you access them and use them in your code?
Really depends on why you added them. (web project, documentation, Web
Browser UI, other).

Hope this helps
Jay
 
Hi Copyco,

As an addition to Herfried,

You can add everything to a Vb.net project.
movies, pictures, html.documents, xmldatasets.

If you are not intended to use them you can better not do that, it uses only
space.

Just my thought.

Cor
 
Herfried said:
What exactly do you want to do with the files?


Well, I was thinking I might be able to dynamically edit the html
document and then export it. Or with the VBScript, pass some parameters
to it from my WinForm code and execute it. Is this possible? Or does
the VBScript have to be external to the project?
 
* copyco said:
Well, I was thinking I might be able to dynamically edit the html
document and then export it. Or with the VBScript, pass some
parameters to it from my WinForm code and execute it. Is this
possible? Or does the VBScript have to be external to the project?

You can add it to the project, but in the output it must still remain a
separate file (not embedded into the application's binary).
 
This is not new to VS2003. We added .doc files to VB6 project to ensure
that all information about a project was kept as one entity. Using this
allowed these documents to be under source control (better than relying on
people to do it themselves). A get latest version of the project would get
all info. This is the same for any type of file.

Think of it as simply a method to organize the data needed to create an
application. Even if the file is not compiled (as a .doc or .bmp/jpg would
be), those files travel with the project/solution.

Lloyd Sheen
 
copyco,
Well, I was thinking I might be able to dynamically edit the html
document and then export it.
Explain "export it", HTML added to a project is going to be "external" to
the binary, which means you will need to add it to your setup project to
have it deployed. Alternatively you can set the "Build Action" to "Embedded
Resource" to have the HTML file embedded into your executable, which means
you may then need to "export it" to a file, to actually use it. The Build
Action is available from the properties window when you select the file in
Solution Explorer. You can use a ResourceManager and/or ResourceReader to
get at the embedded file in your executable.
Or with the VBScript, pass some parameters
to it from my WinForm code and execute it. Is this possible?
You could use either the COM Script control, or Process.Start to exectu
Or does
the VBScript have to be external to the project?
You could have the VBScript embedded in the executable like you can an HTML
file.

Hope this helps
Jay
 
Hi Copyco,

I think that I start to understand what is the basis of your question

With the VS.studio IDE you can make perfect classic HTML websites.

Therefore you need things as javascript, css, vbscript and of course HTML
files.

Cor
 
Jay said:
copyco,


Explain "export it", HTML added to a project is going to be "external" to
the binary, which means you will need to add it to your setup project to
have it deployed. Alternatively you can set the "Build Action" to "Embedded
Resource" to have the HTML file embedded into your executable, which means
you may then need to "export it" to a file, to actually use it. The Build
Action is available from the properties window when you select the file in
Solution Explorer. You can use a ResourceManager and/or ResourceReader to
get at the embedded file in your executable.



You could use either the COM Script control, or Process.Start to exectu



You could have the VBScript embedded in the executable like you can an HTML
file.

Hope this helps
Jay

Ok let's say I have a VBScript file embeded in my executable. How would
I write the code that would execute the script?
 
Copyco,
Ok let's say I have a VBScript file embeded in my executable. How would
I write the code that would execute the script?

First I would have to question WHY? I would simply convert the VBScript to
VB.NET and execute it either directly or dynamically.

If I had a hard requirement to actually execute VBScript, (First I would
seriously consider changing the requirement, see above) then I would
consider using the ResourceManager to read the embedded VBScript file, write
it to a temp file, then use Process.Start to execute the temp file.

Are you asking for me to give you the code to perform the above steps? A
specific step?

To read the resource I would start here:
http://msdn.microsoft.com/library/d...fSystemResourcesResourceManagerClassTopic.asp

http://msdn.microsoft.com/library/d...rfSystemResourcesResourceReaderClassTopic.asp

To write the temp file I would start here:
http://msdn.microsoft.com/library/d.../html/frlrfSystemIOStreamWriterClassTopic.asp

To execute the temp file I would start here:
http://msdn.microsoft.com/library/d...fSystemDiagnosticsProcessClassStartTopic3.asp

Hope this helps
Jay
 
Jay said:
Copyco,
Ok let's say I have a VBScript file embeded in my executable. How would
I write the code that would execute the script?


First I would have to question WHY? I would simply convert the VBScript to
VB.NET and execute it either directly or dynamically.

If I had a hard requirement to actually execute VBScript, (First I would
seriously consider changing the requirement, see above) then I would
consider using the ResourceManager to read the embedded VBScript file, write
it to a temp file, then use Process.Start to execute the temp file.

Are you asking for me to give you the code to perform the above steps? A
specific step?

To read the resource I would start here:
http://msdn.microsoft.com/library/d...fSystemResourcesResourceManagerClassTopic.asp

http://msdn.microsoft.com/library/d...rfSystemResourcesResourceReaderClassTopic.asp

To write the temp file I would start here:
http://msdn.microsoft.com/library/d.../html/frlrfSystemIOStreamWriterClassTopic.asp

To execute the temp file I would start here:
http://msdn.microsoft.com/library/d...fSystemDiagnosticsProcessClassStartTopic3.asp

Hope this helps
Jay

Jay B. Harlow [MVP - Outlook] wrote:

copyco,


Well, I was thinking I might be able to dynamically edit the html
document and then export it.

Explain "export it", HTML added to a project is going to be "external"
to
the binary, which means you will need to add it to your setup project to
have it deployed. Alternatively you can set the "Build Action" to
"Embedded
Resource" to have the HTML file embedded into your executable, which
means
you may then need to "export it" to a file, to actually use it. The
Build
Action is available from the properties window when you select the file
in
Solution Explorer. You can use a ResourceManager and/or ResourceReader
to
get at the embedded file in your executable.



Or with the VBScript, pass some parameters
to it from my WinForm code and execute it. Is this possible?

You could use either the COM Script control, or Process.Start to exectu



Or does
the VBScript have to be external to the project?

You could have the VBScript embedded in the executable like you can an
HTML
file.

Hope this helps
Jay



Herfried K. Wagner [MVP] wrote:



* copyco <[email protected]> scripsit:



Can anyone tell me what the purpose is to adding items such as a
VBScript file or HTML document to your VB.NET project? Once you have
these things added, how to you access them and use them in your code?


What exactly do you want to do with the files?



Well, I was thinking I might be able to dynamically edit the html
document and then export it. Or with the VBScript, pass some parameters
to it from my WinForm code and execute it. Is this possible? Or does
the VBScript have to be external to the project?
Ok let's say I have a VBScript file embeded in my executable. How would
I write the code that would execute the script?
Actually, I'm using System.Web.Mail.MailMessage and
System.Web.Mail.SmtpMail.SmtpServer to send an e-mail message. The
problem is that I have .NET Framework v 1.0 which does not support SMTP
authentication. However, I'm able to write VBSript that does. I just
was wondering how I could execute the script from the executable itself
instead of run it externally. It just seems to be a clumsy way of doing
it.
 
copyco,
How does that saying go: use the right tool for the right job? :-|

Correct! System.Web.Mail does not handle SMTP authentication.

I would think that if you have a VBScript that does authenticated email,
than you can use the same code in VB.NET to also do authenticated email. As
VB.NET handles COM (almost) as easy as VBScript handles COM.

I would think our time would be better served figuring out how to convert
your VBScript code to VB.NET and getting it to run, rather then how to run
VBScript code from .NET...

For starters I would cut & paste the VBScript code into a new VB.NET source
file that has Option Strict Off & Option Explicit Off (which is most
VBScript like).

Hope this helps
Jay

copyco said:
Jay B. Harlow [MVP - Outlook] wrote:
 
Jay said:
copyco,
How does that saying go: use the right tool for the right job? :-|

Correct! System.Web.Mail does not handle SMTP authentication.

I would think that if you have a VBScript that does authenticated email,
than you can use the same code in VB.NET to also do authenticated email. As
VB.NET handles COM (almost) as easy as VBScript handles COM.

I would think our time would be better served figuring out how to convert
your VBScript code to VB.NET and getting it to run, rather then how to run
VBScript code from .NET...

For starters I would cut & paste the VBScript code into a new VB.NET source
file that has Option Strict Off & Option Explicit Off (which is most
VBScript like).

Hope this helps
Jay

Jay B. Harlow [MVP - Outlook] wrote:

Actually, I'm using System.Web.Mail.MailMessage and
System.Web.Mail.SmtpMail.SmtpServer to send an e-mail message. The
problem is that I have .NET Framework v 1.0 which does not support SMTP
authentication. However, I'm able to write VBSript that does. I just
was wondering how I could execute the script from the executable itself
instead of run it externally. It just seems to be a clumsy way of doing
it.

I tried your suggestion but it isn't working. It gives me the error
'The "SendUsing" configuration value is invalid.' However this code
works fine as a VBScript. I'm just about ready to throw up my hands and
just call the script from my executable. Here's the code below.
Perhaps someone can point out the error.
\\\
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim objEmail = CreateObject("CDO.Message")
'Dim objEmail As New CDO.Message()
objEmail.From = "my_email@my_isp.net"
objEmail.To = "(e-mail address removed)"
objEmail.Subject = "test message"
objEmail.TextBody = "This is a test."
objEmail.Sender = "my_email@my_isp.net"

With objEmail.Fields

..Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

..Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"smtp.swbell.yahoo.com"

..Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

..Item("http://schemas.microsoft.com/cdo/configuration/sendusername") =
"my_email@my_isp.net"

..Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") =
"my_password"

..Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
End With

objEmail.Configuration.Fields.Update()

objEmail.Send()

End Sub
///
 
copyco said:
copyco,
How does that saying go: use the right tool for the right job? :-|

Correct! System.Web.Mail does not handle SMTP authentication.

I would think that if you have a VBScript that does authenticated email,
than you can use the same code in VB.NET to also do authenticated
email. As
VB.NET handles COM (almost) as easy as VBScript handles COM.

I would think our time would be better served figuring out how to convert
your VBScript code to VB.NET and getting it to run, rather then how to
run
VBScript code from .NET...

For starters I would cut & paste the VBScript code into a new VB.NET
source
file that has Option Strict Off & Option Explicit Off (which is most
VBScript like).

Hope this helps
Jay

Jay B. Harlow [MVP - Outlook] wrote:


Actually, I'm using System.Web.Mail.MailMessage and
System.Web.Mail.SmtpMail.SmtpServer to send an e-mail message. The
problem is that I have .NET Framework v 1.0 which does not support SMTP
authentication. However, I'm able to write VBSript that does. I just
was wondering how I could execute the script from the executable itself
instead of run it externally. It just seems to be a clumsy way of doing
it.

I tried your suggestion but it isn't working. It gives me the error
'The "SendUsing" configuration value is invalid.' However this code
works fine as a VBScript. I'm just about ready to throw up my hands and
just call the script from my executable. Here's the code below. Perhaps
someone can point out the error.
\\\
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim objEmail = CreateObject("CDO.Message")
'Dim objEmail As New CDO.Message()
objEmail.From = "my_email@my_isp.net"
objEmail.To = "(e-mail address removed)"
objEmail.Subject = "test message"
objEmail.TextBody = "This is a test."
objEmail.Sender = "my_email@my_isp.net"

With objEmail.Fields

.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"smtp.swbell.yahoo.com"

.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") =
"my_email@my_isp.net"

.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") =
"my_password"

.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")
= 1
End With

objEmail.Configuration.Fields.Update()

objEmail.Send()

End Sub
///

Hey nevermind. I got it working. I used the CDO.Configuration object
for the fields and that worked. Thanks for all the help.
 
Back
Top