Showing posts with label example. Show all posts
Showing posts with label example. Show all posts

Wednesday, March 28, 2012

System.Messaging

Hello, I came across a tutorial on uploading files to a databaseand the example code given in it has the following code thatgives an error that says " Name 'Exc' is not declared.", when I build mysolution.

Catch Exc As Exception
Response.Write("Error: " & Exc.Message)
End Try
 I'm trying to get up to speed with this dot net stuff by going through this and other tutorials. I have already added reference to the System.Messaging namespace to my application. What else must I do to make this work. Thank you in advance for your help.

You need an

Imports System.messaging
along with all the other Imports at the top of the program.

Thursday, March 22, 2012

System.Reflection

Is there a way to determine that an assembly is running under an ASP.NET web
application as opposed to a Windows application?
For example, in an ASP.NET application if I call
Assembly.GetExecutingAssembly(), can I determine that the current assembly
is a web application?JV wrote:
> Is there a way to determine that an assembly is running under an ASP.NET w
eb
> application as opposed to a Windows application?
> For example, in an ASP.NET application if I call
> Assembly.GetExecutingAssembly(), can I determine that the current assembly
> is a web application?
>
You can check what class it's derived from, eg WinForm vs WebForm
JV,
I think a good way to test whether or not you are running in an ASP.NET
application is to access the static Current property on the HttpContext
class. If it is not running in ASP.NET, then the property should return
null.
Hope this helps.
- Nicholas Paldino [.NET/C# MVP]
- mvp@.spam.guard.caspershouse.com
"JV" <johnNOSPAMme@.goisc.com> wrote in message
news:OPATXEaJFHA.1280@.TK2MSFTNGP09.phx.gbl...
> Is there a way to determine that an assembly is running under an ASP.NET
> web application as opposed to a Windows application?
> For example, in an ASP.NET application if I call
> Assembly.GetExecutingAssembly(), can I determine that the current assembly
> is a web application?
>
Be aware if your solution doesn't have a reference to System.Web.dll, it
will throw an exception if you access System.Web.HttpContext.
bill
"Nicholas Paldino [.NET/C# MVP]" <mvp@.spam.guard.caspershouse.com> wrote in
message news:Olu$BMaJFHA.1172@.TK2MSFTNGP12.phx.gbl...
> JV,
> I think a good way to test whether or not you are running in an
ASP.NET
> application is to access the static Current property on the HttpContext
> class. If it is not running in ASP.NET, then the property should return
> null.
> Hope this helps.
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - mvp@.spam.guard.caspershouse.com
> "JV" <johnNOSPAMme@.goisc.com> wrote in message
> news:OPATXEaJFHA.1280@.TK2MSFTNGP09.phx.gbl...
assembly
>
bill:
I think you meant to say "yield a compiler error", not "throw an
exception exception"...
Scott
http://www.OdeToCode.com/blogs/scott/
On Thu, 10 Mar 2005 14:08:08 -0600, "William F. Robertson, Jr."
<theman@.nameht.org> wrote:

>Be aware if your solution doesn't have a reference to System.Web.dll, it
>will throw an exception if you access System.Web.HttpContext.
>bill
>
Thanks for making me think about my response. <grin> I actually didn't
even mean exception, infact after reading my response, I think I just
randomly typed something in that sounded good...
Not all threads in a asp.net application have a HttpContext.Current attached
to it. You can use the HttpContext.Current if you want to know if the
calling thread ( current context) is currently processing a request through
the Http Pipeline, but it is not a reliable indicator that the calling
assembly is a windows application, or a web app. Timers, callbacks, user
created threads, etc will have a null value and can be from either.
Thanks for straightening me out Scott!
bill
"Scott Allen" <scott@.nospam.odetocode.com> wrote in message
news:csd131dhjmjjeuh906jql1a5f1l1bepett@.
4ax.com...
> bill:
> I think you meant to say "yield a compiler error", not "throw an
> exception exception"...
> --
> Scott
> http://www.OdeToCode.com/blogs/scott/
> On Thu, 10 Mar 2005 14:08:08 -0600, "William F. Robertson, Jr."
> <theman@.nameht.org> wrote:
>
>
I have not tried this,
but instead of Assembly.GetExecutingAssembly(), try
Assembly.GetEntryAssembly()...
Greetings,
Henning Krause [MVP]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
(http://www.infinitec.de/software/mistaya.aspx)
"JV" <johnNOSPAMme@.goisc.com> wrote in message
news:OPATXEaJFHA.1280@.TK2MSFTNGP09.phx.gbl...
> Is there a way to determine that an assembly is running under an ASP.NET
web
> application as opposed to a Windows application?
> For example, in an ASP.NET application if I call
> Assembly.GetExecutingAssembly(), can I determine that the current assembly
> is a web application?
>

Tuesday, March 13, 2012

System.Reflection

Is there a way to determine that an assembly is running under an ASP.NET web
application as opposed to a Windows application?

For example, in an ASP.NET application if I call
Assembly.GetExecutingAssembly(), can I determine that the current assembly
is a web application?JV wrote:
> Is there a way to determine that an assembly is running under an ASP.NET web
> application as opposed to a Windows application?
> For example, in an ASP.NET application if I call
> Assembly.GetExecutingAssembly(), can I determine that the current assembly
> is a web application?
>
You can check what class it's derived from, eg WinForm vs WebForm
JV,

I think a good way to test whether or not you are running in an ASP.NET
application is to access the static Current property on the HttpContext
class. If it is not running in ASP.NET, then the property should return
null.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mvp@.spam.guard.caspershouse.com

"JV" <johnNOSPAMme@.goisc.com> wrote in message
news:OPATXEaJFHA.1280@.TK2MSFTNGP09.phx.gbl...
> Is there a way to determine that an assembly is running under an ASP.NET
> web application as opposed to a Windows application?
> For example, in an ASP.NET application if I call
> Assembly.GetExecutingAssembly(), can I determine that the current assembly
> is a web application?
Be aware if your solution doesn't have a reference to System.Web.dll, it
will throw an exception if you access System.Web.HttpContext.

bill

"Nicholas Paldino [.NET/C# MVP]" <mvp@.spam.guard.caspershouse.com> wrote in
message news:Olu$BMaJFHA.1172@.TK2MSFTNGP12.phx.gbl...
> JV,
> I think a good way to test whether or not you are running in an
ASP.NET
> application is to access the static Current property on the HttpContext
> class. If it is not running in ASP.NET, then the property should return
> null.
> Hope this helps.
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - mvp@.spam.guard.caspershouse.com
> "JV" <johnNOSPAMme@.goisc.com> wrote in message
> news:OPATXEaJFHA.1280@.TK2MSFTNGP09.phx.gbl...
> > Is there a way to determine that an assembly is running under an ASP.NET
> > web application as opposed to a Windows application?
> > For example, in an ASP.NET application if I call
> > Assembly.GetExecutingAssembly(), can I determine that the current
assembly
> > is a web application?
bill:

I think you meant to say "yield a compiler error", not "throw an
exception exception"...

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 10 Mar 2005 14:08:08 -0600, "William F. Robertson, Jr."
<theman@.nameht.org> wrote:

>Be aware if your solution doesn't have a reference to System.Web.dll, it
>will throw an exception if you access System.Web.HttpContext.
>bill
Thanks for making me think about my response. <grin> I actually didn't
even mean exception, infact after reading my response, I think I just
randomly typed something in that sounded good...

Not all threads in a asp.net application have a HttpContext.Current attached
to it. You can use the HttpContext.Current if you want to know if the
calling thread ( current context) is currently processing a request through
the Http Pipeline, but it is not a reliable indicator that the calling
assembly is a windows application, or a web app. Timers, callbacks, user
created threads, etc will have a null value and can be from either.

Thanks for straightening me out Scott!

bill

"Scott Allen" <scott@.nospam.odetocode.com> wrote in message
news:csd131dhjmjjeuh906jql1a5f1l1bepett@.4ax.com...
> bill:
> I think you meant to say "yield a compiler error", not "throw an
> exception exception"...
> --
> Scott
> http://www.OdeToCode.com/blogs/scott/
> On Thu, 10 Mar 2005 14:08:08 -0600, "William F. Robertson, Jr."
> <theman@.nameht.org> wrote:
> >Be aware if your solution doesn't have a reference to System.Web.dll, it
> >will throw an exception if you access System.Web.HttpContext.
> >bill
I have not tried this,

but instead of Assembly.GetExecutingAssembly(), try
Assembly.GetEntryAssembly()...

Greetings,
Henning Krause [MVP]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
(http://www.infinitec.de/software/mistaya.aspx)

"JV" <johnNOSPAMme@.goisc.com> wrote in message
news:OPATXEaJFHA.1280@.TK2MSFTNGP09.phx.gbl...
> Is there a way to determine that an assembly is running under an ASP.NET
web
> application as opposed to a Windows application?
> For example, in an ASP.NET application if I call
> Assembly.GetExecutingAssembly(), can I determine that the current assembly
> is a web application?

System.Text.RegularExpressions.dll

I'm developing a custom namespace that needs to run a regular expression.
Here is a quick example of what I was doing
Imports System.Text.RegularExpressions
Namespace blah
public class foo
Public Function bar(ByVal strInput as string, strExpression) as boolean
dim rgx as new RegEx
rgx.pattern = strExpression

return rgx.test(strInput)
end function
end class
end namespace
Problem is It gives me an error trying to importSystem.Text.RegularExpressions and the VBC can't find theSystem.Text.RegularExpressions.dll and neither can I when I do a filesearch for it.
This concerns me because this namespace will be used on an asp.netapplication ... what if the host doesn't have that dll either? and whydon't I have that dll? am I missing something somewhere?
please help.
It's a name space. Not necessarily a physical file.
My bet would be that it is in System.dll.

are you sure you are using this code as it is ?
it doesnot seems to be complied !!!

system.text.stringBuilder

how can I add a variable in my system.text.stringbuilder

for example notice the example below

Dim myvar as string
myvar = "something"

Dim mystring as system.text.stringBuilder

mystring.append (" myvar ")

the above code does not work. It puts myvar as the literal text and not the actual value of the variable.

Please help with the syntax.You have to take the quotes out:


mystring.Append(myvar)

Thanks! Another question :) How can i retrieve an item from my datalist. For example I can get the Datakey but how can I get a particular item?

Here is the code I use to obtain the datakeys

Dim dlItem As DataListItem
For Each dlItem In detailsgrid.Items
' reference the TextBox
Dim txtItems As TextBox = CType(dlItem.FindControl("item_received"), TextBox)
' Grab the value
item_recieved = txtItems.Text
' Get the order number from DataKeys
order_num = detailsgrid.DataKeys(dlItem.ItemIndex).ToString()