Showing posts with label create. Show all posts
Showing posts with label create. Show all posts

Saturday, March 31, 2012

System.Drawing.Image.FromFile from URL?

can i create a system.drawing.Image from a url. using
http://www.domain.com/image.jpg instead of c:\image.jpg. ?
thanks!No, but you can use the WebClient or WebRequest classes to bring the
bytes to the local computer and then create the Image obect.
HTH,
Scott
http://www.OdeToCode.com
On 18 Sep 2004 09:23:29 -0700, jcharth@.hotmail.com (Joseph) wrote:

>can i create a system.drawing.Image from a url. using
>http://www.domain.com/image.jpg instead of c:\image.jpg. ?
>thanks!
As scott mentioned, you do not have any method that can directly read the
image from URL.
Use webclient and read it into a byte[] using DownloadData
then you Image class to load it
Regards,
Hermit Dave
(http://hdave.blogspot.com)
"Joseph" <jcharth@.hotmail.com> wrote in message
news:2f2b8b0b.0409180823.2a6f2f18@.posting.google.com...
> can i create a system.drawing.Image from a url. using
> http://www.domain.com/image.jpg instead of c:\image.jpg. ?
> thanks!

System.Drawing.Image.FromFile from URL?

can i create a system.drawing.Image from a url. using
http://www.domain.com/image.jpg instead of c:\image.jpg. ?
thanks!No, but you can use the WebClient or WebRequest classes to bring the
bytes to the local computer and then create the Image obect.

HTH,

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

On 18 Sep 2004 09:23:29 -0700, jcharth@.hotmail.com (Joseph) wrote:

>can i create a system.drawing.Image from a url. using
>http://www.domain.com/image.jpg instead of c:\image.jpg. ?
>thanks!
As scott mentioned, you do not have any method that can directly read the
image from URL.
Use webclient and read it into a byte[] using DownloadData
then you Image class to load it

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Joseph" <jcharth@.hotmail.com> wrote in message
news:2f2b8b0b.0409180823.2a6f2f18@.posting.google.c om...
> can i create a system.drawing.Image from a url. using
> http://www.domain.com/image.jpg instead of c:\image.jpg. ?
> thanks!

System.Drawing.Text font question

Hello,

I've looked for answer to this everywhere but with no luck..

I need to dynamically create graphic text from database values. I've got this working fine if I use arial as the font but I want to use another font.

Now - presumably I can use any font installed on the server? But it doesn't seem to work. I want to use a font called blurLight but it just outputs in arial (I think - it's a standard font anyway)

Is there anything else I need to do to make other fonts available to asp.net other than just installing them on the server???

Thank you.Post some code so we can have a looksie
Alright - I will

<%@. Page Language="VB" Debug="True" %>
<%@. Import Namespace="System.Drawing" %>
<%@. Import Namespace="System.Drawing.Imaging" %>
<%@. Import Namespace="System.Drawing.Text" %>
<%
' Declare Vars
Dim objBMP As System.Drawing.Bitmap
Dim objGraphics As System.Drawing.Graphics
Dim objFont As System.Drawing.Font

objBMP = New Bitmap(100, 30)

objGraphics = System.Drawing.Graphics.FromImage(objBMP)

objGraphics.Clear(Color.Green)

objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias

objFont = New Font("Arial", 16, FontStyle.Bold)

objGraphics.DrawString("Hello World", objFont, Brushes.White, 3, 3)

Response.ContentType = "image/GIF"
objBMP.Save(Response.OutputStream, ImageFormat.Gif)

objFont.Dispose()
objGraphics.Dispose()
objBMP.Dispose()
%

That code works fine but when I replace Arial with the font I want to use - it doesn't work..

Any ideas??

Wednesday, March 28, 2012

System.IO.IOException: Cannot create a file when that file already exists.

Getting the following error on my production server whether the file exists
or not:

"System.IO.IOException: Cannot create a file when that file already exists."

Here's the code generating the error (seems to be happening when I try
creating a directory)

If dirmgr.Exists("s:\blah\" & txt_name.Text) Then
lblerror.Text = lblerror.Text & "Unable to build physical path. " &
txt_name.Text & " & Contact Dev Team.<BR>"
Else
dirmgr.CreateDirectory("s:\blah\" & txt_name.Text)

This code runs fine on my development server (only the path is c:\blah\blah
instead of S). Also, my production server has failover cluser, and the s
drive is the failover drive. I can't imagine that could be a problem, but
thought I would mention it.

Asside from that, the only other thing I can think of is that the framework
version on my dev box says 1.1, and the one on my production server says:
1.0.37 - surely that's not the cause is it? Permissions shouldn't be an
issue (i've even tried as domain admin)

I would appreciate any help on this, as I'm out of ideas, and can find no
other documentation on this.
- ChadHi,

the default user that runs web application (system) dont has rights to
access network resources.

Natty Gur, CTO
Dao2Com Ltd.
34th Elkalay st. Raanana
Israel , 43000
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
I agree with Natty. The problem you are having is most likely caused by
having no right to access network resources. Willy address a similar
problem before. See
http://groups.google.com/groups?q=S...et&start=10&hl=
en&lr=&ie=UTF-8&oe=UTF-8&selm=OELVHLBNCHA.2460%40tkmsftngp04&rnum=20.

HTH,
-Allen

Disclaimer:
This posting is provided "AS IS" with no warranties, and confers no rights.
Got .Net? http://www.gotdotnet.com

-------
| From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
| Subject: System.IO.IOException: Cannot create a file when that file
already exists.
| Date: Wed, 6 Aug 2003 17:08:27 -0400
| Lines: 29
|
| Getting the following error on my production server whether the file
exists
| or not:
|
| "System.IO.IOException: Cannot create a file when that file already
exists."
|
| Here's the code generating the error (seems to be happening when I try
| creating a directory)
|
| If dirmgr.Exists("s:\blah\" & txt_name.Text) Then
| lblerror.Text = lblerror.Text & "Unable to build physical path. "
&
| txt_name.Text & " & Contact Dev Team.<BR>"
| Else
| dirmgr.CreateDirectory("s:\blah\" & txt_name.Text)
|
| This code runs fine on my development server (only the path is
c:\blah\blah
| instead of S). Also, my production server has failover cluser, and the s
| drive is the failover drive. I can't imagine that could be a problem, but
| thought I would mention it.
|
| Asside from that, the only other thing I can think of is that the
framework
| version on my dev box says 1.1, and the one on my production server says:
| 1.0.37 - surely that's not the cause is it? Permissions shouldn't be an
| issue (i've even tried as domain admin)
|
| I would appreciate any help on this, as I'm out of ideas, and can find no
| other documentation on this.
| - Chad
|
|
|
Thanks for the response.

I understand that, but I'm trying to create a directory on the local drive.
This isn't a mapped share. The drive is physically present on the web
server, and if that web server fails, the other system physically takes over
the drive (ie, a cluster). I've also added the local ASPNET account to the
NTFS permissions on the folder, and it still fails.

- Chad

"[MSFT]Allen" <yweng@.online.microsoft.com> wrote in message
news:j1MRYHMXDHA.2108@.cpmsftngxa06.phx.gbl...
> I agree with Natty. The problem you are having is most likely caused by
> having no right to access network resources. Willy address a similar
> problem before. See
http://groups.google.com/groups?q=S...et&start=10&hl=
> en&lr=&ie=UTF-8&oe=UTF-8&selm=OELVHLBNCHA.2460%40tkmsftngp04&rnum=20.
> HTH,
> -Allen
> Disclaimer:
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> Got .Net? http://www.gotdotnet.com
> -------
> | From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
> | Subject: System.IO.IOException: Cannot create a file when that file
> already exists.
> | Date: Wed, 6 Aug 2003 17:08:27 -0400
> | Lines: 29
> |
> | Getting the following error on my production server whether the file
> exists
> | or not:
> |
> | "System.IO.IOException: Cannot create a file when that file already
> exists."
> |
> | Here's the code generating the error (seems to be happening when I try
> | creating a directory)
> |
> | If dirmgr.Exists("s:\blah\" & txt_name.Text) Then
> | lblerror.Text = lblerror.Text & "Unable to build physical path.
"
> &
> | txt_name.Text & " & Contact Dev Team.<BR>"
> | Else
> | dirmgr.CreateDirectory("s:\blah\" & txt_name.Text)
> |
> | This code runs fine on my development server (only the path is
> c:\blah\blah
> | instead of S). Also, my production server has failover cluser, and the
s
> | drive is the failover drive. I can't imagine that could be a problem,
but
> | thought I would mention it.
> |
> | Asside from that, the only other thing I can think of is that the
> framework
> | version on my dev box says 1.1, and the one on my production server
says:
> | 1.0.37 - surely that's not the cause is it? Permissions shouldn't be an
> | issue (i've even tried as domain admin)
> |
> | I would appreciate any help on this, as I'm out of ideas, and can find
no
> | other documentation on this.
> | - Chad
> |
> |
> |
It doesn't work creating folders under the same directory as the web
application... same issue.

I'm going to try figuring out why that server is showing that it's running
version 1.03 of the dotnet framework. It shows that v1.1 was installed.

Thanks,
Chad

"[MSFT]Allen" <yweng@.online.microsoft.com> wrote in message
news:RT0i6ZXXDHA.2184@.cpmsftngxa06.phx.gbl...
> Try creating a directory in your code under the folder where your web
> application resides. Does it works? In addition, you may want to verify
the
> account your web application is running under. Please download tokedump
> written by Keith Brown from
> http://msdn.microsoft.com/msdnmag/i...ty/default.aspx. It
> would show you what account the application is running under.
> -Allen
> Disclaimer:
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> Got .Net? http://www.gotdotnet.com
> -------
> | From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
> | References: <uaJhi7FXDHA.1900@.TK2MSFTNGP10.phx.gbl>
> <j1MRYHMXDHA.2108@.cpmsftngxa06.phx.gbl>
> | Subject: Re: System.IO.IOException: Cannot create a file when that file
> already exists.
> | Date: Thu, 7 Aug 2003 08:11:44 -0400
> | Lines: 78
> | X-Priority: 3
> | X-MSMail-Priority: Normal
> | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
> | Message-ID: <exrIT0NXDHA.1204@.TK2MSFTNGP12.phx.gbl>
> | Newsgroups: microsoft.public.dotnet.framework.aspnet
> | NNTP-Posting-Host: 12.108.244.117
> | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
> | Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet:165699
> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
> |
> | Thanks for the response.
> |
> | I understand that, but I'm trying to create a directory on the local
> drive.
> | This isn't a mapped share. The drive is physically present on the web
> | server, and if that web server fails, the other system physically takes
> over
> | the drive (ie, a cluster). I've also added the local ASPNET account to
> the
> | NTFS permissions on the folder, and it still fails.
> |
> | - Chad
> |
> |
> | "[MSFT]Allen" <yweng@.online.microsoft.com> wrote in message
> | news:j1MRYHMXDHA.2108@.cpmsftngxa06.phx.gbl...
> | > I agree with Natty. The problem you are having is most likely caused
by
> | > having no right to access network resources. Willy address a similar
> | > problem before. See
> | >
> |
http://groups.google.com/groups?q=S...et&start=10&hl=
> | > en&lr=&ie=UTF-8&oe=UTF-8&selm=OELVHLBNCHA.2460%40tkmsftngp04&rnum=20.
> | >
> | > HTH,
> | > -Allen
> | >
> | > Disclaimer:
> | > This posting is provided "AS IS" with no warranties, and confers no
> | rights.
> | > Got .Net? http://www.gotdotnet.com
> | >
> | > -------
> | > | From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
> | > | Subject: System.IO.IOException: Cannot create a file when that file
> | > already exists.
> | > | Date: Wed, 6 Aug 2003 17:08:27 -0400
> | > | Lines: 29
> | > |
> | > | Getting the following error on my production server whether the file
> | > exists
> | > | or not:
> | > |
> | > | "System.IO.IOException: Cannot create a file when that file already
> | > exists."
> | > |
> | > | Here's the code generating the error (seems to be happening when I
try
> | > | creating a directory)
> | > |
> | > | If dirmgr.Exists("s:\blah\" & txt_name.Text) Then
> | > | lblerror.Text = lblerror.Text & "Unable to build physical
> path.
> | "
> | > &
> | > | txt_name.Text & " & Contact Dev Team.<BR>"
> | > | Else
> | > | dirmgr.CreateDirectory("s:\blah\" & txt_name.Text)
> | > |
> | > | This code runs fine on my development server (only the path is
> | > c:\blah\blah
> | > | instead of S). Also, my production server has failover cluser, and
> the
> | s
> | > | drive is the failover drive. I can't imagine that could be a
problem,
> | but
> | > | thought I would mention it.
> | > |
> | > | Asside from that, the only other thing I can think of is that the
> | > framework
> | > | version on my dev box says 1.1, and the one on my production server
> | says:
> | > | 1.0.37 - surely that's not the cause is it? Permissions shouldn't
be
> an
> | > | issue (i've even tried as domain admin)
> | > |
> | > | I would appreciate any help on this, as I'm out of ideas, and can
find
> | no
> | > | other documentation on this.
> | > | - Chad
> | > |
> | > |
> | > |
> | >
> |
> |
> |
Chad, was the problem resolved? It seems that you installed both v1.03 and
v1.1 on the same web server. If so, it might be helpful to look at the
article "Compatibility Considerations and Version Changes" on
http://www.gotdotnet.com/team/changeinfo/default.aspx. Try configuring your
web application to run V1.03 and V1.1 specifically to see how it works.

-Allen

Disclaimer:
This posting is provided "AS IS" with no warranties, and confers no rights.
Got .Net? http://www.gotdotnet.com

-------
| From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
| References: <uaJhi7FXDHA.1900@.TK2MSFTNGP10.phx.gbl>
<j1MRYHMXDHA.2108@.cpmsftngxa06.phx.gbl>
<exrIT0NXDHA.1204@.TK2MSFTNGP12.phx.gbl>
<RT0i6ZXXDHA.2184@.cpmsftngxa06.phx.gbl>
| Subject: Re: System.IO.IOException: Cannot create a file when that file
already exists.
| Date: Mon, 11 Aug 2003 01:16:22 -0400
| Lines: 141
|
|
| It doesn't work creating folders under the same directory as the web
| application... same issue.
|
| I'm going to try figuring out why that server is showing that it's running
| version 1.03 of the dotnet framework. It shows that v1.1 was installed.
|
| Thanks,
| Chad
|
| "[MSFT]Allen" <yweng@.online.microsoft.com> wrote in message
| news:RT0i6ZXXDHA.2184@.cpmsftngxa06.phx.gbl...
| > Try creating a directory in your code under the folder where your web
| > application resides. Does it works? In addition, you may want to verify
| the
| > account your web application is running under. Please download tokedump
| > written by Keith Brown from
| > http://msdn.microsoft.com/msdnmag/i...ty/default.aspx. It
| > would show you what account the application is running under.
| >
| > -Allen
| >
| > Disclaimer:
| > This posting is provided "AS IS" with no warranties, and confers no
| rights.
| > Got .Net? http://www.gotdotnet.com
| >
| > -------
| > | From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
| > | References: <uaJhi7FXDHA.1900@.TK2MSFTNGP10.phx.gbl>
| > <j1MRYHMXDHA.2108@.cpmsftngxa06.phx.gbl>
| > | Subject: Re: System.IO.IOException: Cannot create a file when that
file
| > already exists.
| > | Date: Thu, 7 Aug 2003 08:11:44 -0400
| > | Lines: 78
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| > | Message-ID: <exrIT0NXDHA.1204@.TK2MSFTNGP12.phx.gbl>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | NNTP-Posting-Host: 12.108.244.117
| > | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
| > | Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.framework.aspnet:165699
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| > |
| > | Thanks for the response.
| > |
| > | I understand that, but I'm trying to create a directory on the local
| > drive.
| > | This isn't a mapped share. The drive is physically present on the
web
| > | server, and if that web server fails, the other system physically
takes
| > over
| > | the drive (ie, a cluster). I've also added the local ASPNET account
to
| > the
| > | NTFS permissions on the folder, and it still fails.
| > |
| > | - Chad
| > |
| > |
| > | "[MSFT]Allen" <yweng@.online.microsoft.com> wrote in message
| > | news:j1MRYHMXDHA.2108@.cpmsftngxa06.phx.gbl...
| > | > I agree with Natty. The problem you are having is most likely caused
| by
| > | > having no right to access network resources. Willy address a similar
| > | > problem before. See
| > | >
| > |
| >
|
http://groups.google.com/groups?q=S...et&start=10&hl=
| > | >
en&lr=&ie=UTF-8&oe=UTF-8&selm=OELVHLBNCHA.2460%40tkmsftngp04&rnum=20.
| > | >
| > | > HTH,
| > | > -Allen
| > | >
| > | > Disclaimer:
| > | > This posting is provided "AS IS" with no warranties, and confers no
| > | rights.
| > | > Got .Net? http://www.gotdotnet.com
| > | >
| > | > -------
| > | > | From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
| > | > | Subject: System.IO.IOException: Cannot create a file when that
file
| > | > already exists.
| > | > | Date: Wed, 6 Aug 2003 17:08:27 -0400
| > | > | Lines: 29
| > | > |
| > | > | Getting the following error on my production server whether the
file
| > | > exists
| > | > | or not:
| > | > |
| > | > | "System.IO.IOException: Cannot create a file when that file
already
| > | > exists."
| > | > |
| > | > | Here's the code generating the error (seems to be happening when I
| try
| > | > | creating a directory)
| > | > |
| > | > | If dirmgr.Exists("s:\blah\" & txt_name.Text) Then
| > | > | lblerror.Text = lblerror.Text & "Unable to build physical
| > path.
| > | "
| > | > &
| > | > | txt_name.Text & " & Contact Dev Team.<BR>"
| > | > | Else
| > | > | dirmgr.CreateDirectory("s:\blah\" & txt_name.Text)
| > | > |
| > | > | This code runs fine on my development server (only the path is
| > | > c:\blah\blah
| > | > | instead of S). Also, my production server has failover cluser,
and
| > the
| > | s
| > | > | drive is the failover drive. I can't imagine that could be a
| problem,
| > | but
| > | > | thought I would mention it.
| > | > |
| > | > | Asside from that, the only other thing I can think of is that the
| > | > framework
| > | > | version on my dev box says 1.1, and the one on my production
server
| > | says:
| > | > | 1.0.37 - surely that's not the cause is it? Permissions shouldn't
| be
| > an
| > | > | issue (i've even tried as domain admin)
| > | > |
| > | > | I would appreciate any help on this, as I'm out of ideas, and can
| find
| > | no
| > | > | other documentation on this.
| > | > | - Chad
| > | > |
| > | > |
| > | > |
| > | >
| > |
| > |
| > |
| >
|
|
|
Allen,

Thanks for the followup. I actually got my program working late last night.
The problem was the framework version.

I tried simply configuring the web application to use version 1.1, but that
didn't help. I also tried uninstalling then reinstalling framework version
1.1, but that also didn't get IIS to start using version 1.1 by default. I
consequently uninstalled versions 1.1 *and* version 1.03, then only
reinstalled version 1.1 again, and this took care of the problem.

Thanks again for all the help everyone!

- Chad

"[MSFT]Allen" <yweng@.online.microsoft.com> wrote in message
news:hNsBh8sYDHA.2352@.cpmsftngxa06.phx.gbl...
> Chad, was the problem resolved? It seems that you installed both v1.03 and
> v1.1 on the same web server. If so, it might be helpful to look at the
> article "Compatibility Considerations and Version Changes" on
> http://www.gotdotnet.com/team/changeinfo/default.aspx. Try configuring
your
> web application to run V1.03 and V1.1 specifically to see how it works.
> -Allen
> Disclaimer:
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> Got .Net? http://www.gotdotnet.com
> -------
> | From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
> | References: <uaJhi7FXDHA.1900@.TK2MSFTNGP10.phx.gbl>
> <j1MRYHMXDHA.2108@.cpmsftngxa06.phx.gbl>
> <exrIT0NXDHA.1204@.TK2MSFTNGP12.phx.gbl>
> <RT0i6ZXXDHA.2184@.cpmsftngxa06.phx.gbl>
> | Subject: Re: System.IO.IOException: Cannot create a file when that file
> already exists.
> | Date: Mon, 11 Aug 2003 01:16:22 -0400
> | Lines: 141
> |
> |
> | It doesn't work creating folders under the same directory as the web
> | application... same issue.
> |
> | I'm going to try figuring out why that server is showing that it's
running
> | version 1.03 of the dotnet framework. It shows that v1.1 was installed.
> |
> | Thanks,
> | Chad
> |
> | "[MSFT]Allen" <yweng@.online.microsoft.com> wrote in message
> | news:RT0i6ZXXDHA.2184@.cpmsftngxa06.phx.gbl...
> | > Try creating a directory in your code under the folder where your web
> | > application resides. Does it works? In addition, you may want to
verify
> | the
> | > account your web application is running under. Please download
tokedump
> | > written by Keith Brown from
> | > http://msdn.microsoft.com/msdnmag/i...ty/default.aspx.
It
> | > would show you what account the application is running under.
> | >
> | > -Allen
> | >
> | > Disclaimer:
> | > This posting is provided "AS IS" with no warranties, and confers no
> | rights.
> | > Got .Net? http://www.gotdotnet.com
> | >
> | > -------
> | > | From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
> | > | References: <uaJhi7FXDHA.1900@.TK2MSFTNGP10.phx.gbl>
> | > <j1MRYHMXDHA.2108@.cpmsftngxa06.phx.gbl>
> | > | Subject: Re: System.IO.IOException: Cannot create a file when that
> file
> | > already exists.
> | > | Date: Thu, 7 Aug 2003 08:11:44 -0400
> | > | Lines: 78
> | > | X-Priority: 3
> | > | X-MSMail-Priority: Normal
> | > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
> | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
> | > | Message-ID: <exrIT0NXDHA.1204@.TK2MSFTNGP12.phx.gbl>
> | > | Newsgroups: microsoft.public.dotnet.framework.aspnet
> | > | NNTP-Posting-Host: 12.108.244.117
> | > | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
> | > | Xref: cpmsftngxa06.phx.gbl
> | microsoft.public.dotnet.framework.aspnet:165699
> | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
> | > |
> | > | Thanks for the response.
> | > |
> | > | I understand that, but I'm trying to create a directory on the local
> | > drive.
> | > | This isn't a mapped share. The drive is physically present on the
> web
> | > | server, and if that web server fails, the other system physically
> takes
> | > over
> | > | the drive (ie, a cluster). I've also added the local ASPNET account
> to
> | > the
> | > | NTFS permissions on the folder, and it still fails.
> | > |
> | > | - Chad
> | > |
> | > |
> | > | "[MSFT]Allen" <yweng@.online.microsoft.com> wrote in message
> | > | news:j1MRYHMXDHA.2108@.cpmsftngxa06.phx.gbl...
> | > | > I agree with Natty. The problem you are having is most likely
caused
> | by
> | > | > having no right to access network resources. Willy address a
similar
> | > | > problem before. See
> | > | >
> | > |
> | >
> |
http://groups.google.com/groups?q=S...et&start=10&hl=
> | > | >
> en&lr=&ie=UTF-8&oe=UTF-8&selm=OELVHLBNCHA.2460%40tkmsftngp04&rnum=20.
> | > | >
> | > | > HTH,
> | > | > -Allen
> | > | >
> | > | > Disclaimer:
> | > | > This posting is provided "AS IS" with no warranties, and confers
no
> | > | rights.
> | > | > Got .Net? http://www.gotdotnet.com
> | > | >
> | > | > -------
> | > | > | From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
> | > | > | Subject: System.IO.IOException: Cannot create a file when that
> file
> | > | > already exists.
> | > | > | Date: Wed, 6 Aug 2003 17:08:27 -0400
> | > | > | Lines: 29
> | > | > |
> | > | > | Getting the following error on my production server whether the
> file
> | > | > exists
> | > | > | or not:
> | > | > |
> | > | > | "System.IO.IOException: Cannot create a file when that file
> already
> | > | > exists."
> | > | > |
> | > | > | Here's the code generating the error (seems to be happening when
I
> | try
> | > | > | creating a directory)
> | > | > |
> | > | > | If dirmgr.Exists("s:\blah\" & txt_name.Text) Then
> | > | > | lblerror.Text = lblerror.Text & "Unable to build
physical
> | > path.
> | > | "
> | > | > &
> | > | > | txt_name.Text & " & Contact Dev Team.<BR>"
> | > | > | Else
> | > | > | dirmgr.CreateDirectory("s:\blah\" & txt_name.Text)
> | > | > |
> | > | > | This code runs fine on my development server (only the path is
> | > | > c:\blah\blah
> | > | > | instead of S). Also, my production server has failover cluser,
> and
> | > the
> | > | s
> | > | > | drive is the failover drive. I can't imagine that could be a
> | problem,
> | > | but
> | > | > | thought I would mention it.
> | > | > |
> | > | > | Asside from that, the only other thing I can think of is that
the
> | > | > framework
> | > | > | version on my dev box says 1.1, and the one on my production
> server
> | > | says:
> | > | > | 1.0.37 - surely that's not the cause is it? Permissions
shouldn't
> | be
> | > an
> | > | > | issue (i've even tried as domain admin)
> | > | > |
> | > | > | I would appreciate any help on this, as I'm out of ideas, and
can
> | find
> | > | no
> | > | > | other documentation on this.
> | > | > | - Chad
> | > | > |
> | > | > |
> | > | > |
> | > | >
> | > |
> | > |
> | > |
> | >
> |
> |
> |

System.IO.Path.GetTempFileName

Hi,
System.IO.Path.GetTempFileName( ) is supposed to create a temporary file and give us the path to the created file.
By default, where does this temp file get created? C:\Temp, C:\WinNT ?
Bcos right now this fails and error we get is "Access denied". But we dont know which folder's permissions to change as we dont know where this temp file is supposed to get created.

It will be in the ASPNET user's Temp Directory. For example, on mine:
C:\Documents and Settings\ComputerName\ASPNET\Local Settings\Temp


You are right ! I just found that out by using

tempPathString = Path.GetTempPath()
Thanks !


correctomundo!!
I know this is an old post, but System.IO.Path.GetTempPath() only puts stuff in the ASPNET user directory when the app runs on XP Pro. That is fine for development, but when the app is deployed to a Windows 2003 server the method returns C:\Windows\Temp. Calling GetTempFileName() creates a temp file there. Surely, it isn't safe or a best practice to write to the Windows directory, is it?

Saturday, March 24, 2012

System.Net.Mail.SmtpClient.Send() Error: An invalid character was found in the mail header

hi all!

please help!

I wanted to make an automatic email when I create user by CreateUserWizard. So I configured SMTP, then in properties of the wizard indicated textfile for message and wrote simple subject "registration"

but I have an exception (like in subj).

I even tried to set the subject in event handler for "emailsending" event. Same exception.

What is wrong? How could I fix it?

Here us some info from stack:

[FormatException:An invalid character was found in the mail header.] System.Net.BufferBuilder.Append(String value, Int32 offset, Int32 count) +915954 System.Net.Mail.EHelloCommand.PrepareCommand(SmtpConnection conn, String domain) +106 System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) +835 System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) +316 System.Net.Mail.SmtpClient.GetConnection() +42 System.Net.Mail.SmtpClient.Send(MailMessage message) +1485

[SmtpException: Email send failure.] System.Net.Mail.SmtpClient.Send(MailMessage message) +2074 System.Web.UI.WebControls.LoginUtil.SendPasswordMail(String email, String userName, String password, MailDefinition mailDefinition, String defaultSubject, String defaultBody, OnSendingMailDelegate onSendingMailDelegate, OnSendMailErrorDelegate onSendMailErrorDelegate, Control owner) +341 System.Web.UI.WebControls.CreateUserWizard.AttemptCreateUser() +571 System.Web.UI.WebControls.CreateUserWizard.OnNextButtonClick(WizardNavigationEventArgs e) +105 System.Web.UI.WebControls.Wizard.OnBubbleEvent(Object source, EventArgs e) +453 System.Web.UI.WebControls.CreateUserWizard.OnBubbleEvent(Object source, EventArgs e) +149 System.Web.UI.WebControls.WizardChildTable.OnBubbleEvent(Object source, EventArgs args) +17 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35 System.Web.UI.WebControls.ImageButton.OnCommand(CommandEventArgs e) +115 System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +171 System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102

Hi there, can i just ask why you choose me? as for your problem, it looks like there is an invalid character in the mail header, so either there is nothing in it or something there shouldnt be, try taking a few steps back, if your attaching a text file just simply put a few words coded in, and if your header is dynamic try making it hard coded


You were online. Sorry.

It is more simple. There is simpliest string, like "123". Same error


hey no worries, well try a string like abc, also make sure no fields are not left blank. What usually helps me is take a 10 min break, clear you head have a coffee and come back look through your code as if you have never seen it before. something may catch. Im not the worlds best .neter but i usually find if there is a problem its often by taking things back to basic it helps


If your still not having any success you could try the code below and see if it makes any difference.

Regards

Martijn

Sub mailout()Dim mailAsNew Net.Mail.MailMessage()

'set the addresses

mail.To.Add("recipient@.whereever.com")

mail.From =New Net.Mail.MailAddress("sender@.wherever.com"))

'set the content

mail.Subject ="Email Subject line"

mail.Body ="The main body of the email message"

'send the message

Dim smtpAsNew Net.Mail.SmtpClient("smtp.whereever.com")

'to authenticate we set the username and password properites on the SmtpClient

smtp.Credentials =New Net.NetworkCredential("smtp-accountname e.g. sender@.wherever.com","smtp-account-password")

Try

smtp.Send(mail)

response.write("Email sent successfully")

Catch ExAs Exception

response.write("Email send failed error code is... " & Ex.Message)

EndTry

EndSub


no success, same error


I cant come up with any conclusions from your stack trace.

The code I gave you I copied out of an application I wrote there was something I had missed and should have cleaned up in the following line

mail.From =New Net.Mail.MailAddress(Session(sender@.wherever.com))

It should be this (no reference to any session variable)

mail.From =New Net.Mail.MailAddress(sender@.wherever.com)

The only other question is does your recipient or sender email address have any unusual charactors or attempt to have a space in it? Any thing like that could cause a problem. Try the same code with different email addresses and different content.

Sorry no other suggestions

Martijn


May be this piece of code will help:

<system.net>
<mailSettings>
<smtp from="evdokp@.pochta.ru">
<network host="mail.pochta.ru" password="[мой пароль]" userName="evdokp@.pochta.ru" />
</smtp>
</mailSettings>
</system.net>

this is how ASP.NET build-it configuration tool edits web.config

Well, my additional question is: where does the tool sets port value?


ok, my sugesstion is to take remove the brackets from the password and to use a password with standard English character set without and spaces.

Be sure to update the password on the mail server too.

Good luck

<system.net>
<mailSettings>
<smtp from="evdokp@.pochta.ru">
<network host="mail.pochta.ru" password="myPassword" userName="evdokp@.pochta.ru" />
</smtp>
</mailSettings>
</system.net>


it is not that easy.

these brackets are there just because I hide my password. It was like you say "myPassword"

Do you know where port is defined in web.config?

Tuesday, March 13, 2012

System.Runtime.InteropServices.COMException + Unspecified Error

Hi..

I am using AD and SQL Authentication in my site. I am using ASP.NET 2.0+C#.

I have a web page, in which i can create users. While I try to create an user for the first time, I am getting anUnspecified Error. Repeated trials are successfully creating users in the database and AD, I am using the Authentication mode as:SQL_and_AD_Authentication

In my information log, I have the following stack trace:

Timestamp: 24/09/2007 14:27:32
Message: HandlingInstanceID: 272245f4-2d0a-422a-8d7d-0fdf66ad1b44
An exception of type 'System.Runtime.InteropServices.COMException' occurred and was caught.
----------------------------
09/24/2007 15:27:32
Type : System.Runtime.InteropServices.COMException, mscorlib, Version=2.0.0.0, Culture=neutral,

Message : Unspecified error

Source : App_Web_2b_1-umr
Help link :
ErrorCode : -2147467259
Data : System.Collections.ListDictionaryInternal
TargetSite : Void AddUser()
Stack Trace : at MyAdmin.UI.SiteViewAgents.AddUser()
at MyAdmin.UI.SiteViewAgents.UpdateAgent(String AgentId)

Additional Info:

MachineName : CCQASRV
TimeStamp : 24/09/2007 14:27:32
FullName : Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null

ThreadIdentity :
WindowsIdentity : BTCCOUTBOUND\Administrator

Category: Error
Priority: 0
EventId: 100
Severity: Error
Title:Enterprise Library Exception Handling
Machine: CCQASRV
Application Domain: /LM/W3SVC/1/Root/NGCCManagementFrameworkAdmin_QA2.1-1-128351114095156250
Process Id: 6196
Process Name: c:\windows\system32\inetsrv\w3wp.exe
Win32 Thread Id: 8480
Thread Name:
Extended Properties:

what is this Unspecified Error? Please help..

Thanks

Check this thread to see if it gives some pointers

http://www.eggheadcafe.com/software/aspnet/29434778/cannot-add-user-to-active.aspx

HTH,
Suprotim Agarwal

--
http://www.dotnetcurry.com
--


Hi..

Thank you very much for the reply.. But I couldn't get much help from that.

Thanks


Hi,

In that case, try posting the code which you feel causes the error.

Suprotim.


Hi venkatzeus,

According to MSDN, if the HRESULT is a custom result or if it is unknown to the runtime, the runtime passes a genericCOMException to the client. TheErrorCode property of theCOMException contains the HRESULT value. You can use catch(ComException ex) to catch this type of exception.

http://msdn2.microsoft.com/en-us/library/system.runtime.interopservices.comexception(VS.71).aspx

Hope it helps.


HI..

I searched in google and found out this:

http://support.microsoft.com/kb/232282

It says, it is a Generic COM Error Codes. How to catch these generic COM Error codes and provide more meaningful messages to the end user.

Thanks

loadTOCNode(2, 'moreinformation');

System.Security.SecurityException: Permission denied Error while invoking methods in a Com

Hi,
I am getting an error while trying to create an excel file.
"Description: The application attempted to perform an operation not allowed
by the security policy. To grant this application the required permission
please contact your system administrator or change the application's trust
level in the configuration file.
Exception Details: System.Security.SecurityException: Permission denied"

This is what I am doing. we had an app that was written in VB to take
specific dates and create an excel file.
I am using the dll in my .NET app but it displays the error while writing
the file...

I am sure that I have used regsrv32 to register the DLL

any suggestions,
Stephenyou said you are using the COM server DLL directly in .net? If thats
what you are doing.. you need to create an interop assembly before you
can access the methods in that dll

Please let me know if I understoof your question incorrectly

stephen wrote:

Quote:

Originally Posted by

Hi,
I am getting an error while trying to create an excel file.
"Description: The application attempted to perform an operation not allowed
by the security policy. To grant this application the required permission
please contact your system administrator or change the application's trust
level in the configuration file.
Exception Details: System.Security.SecurityException: Permission denied"
>
This is what I am doing. we had an app that was written in VB to take
specific dates and create an excel file.
I am using the dll in my .NET app but it displays the error while writing
the file...
>
I am sure that I have used regsrv32 to register the DLL
>
any suggestions,
Stephen


Are you trying to run the application over the network? If so, see
http://blogs.msdn.com/shawnfa/archi...6/20/57023.aspx. (If you're
using version 2.0 of the .NET framework, ClickOnce is another option for
permissions elevation.)

If you're not attempting to run the applicaiton over the network, could you
please post the complete exception details (including call stack listing),
as returned from its ToString method?

"stephen" <stephen_jn@.hotmail.comwrote in message
news:%23F0g$XxuGHA.324@.TK2MSFTNGP06.phx.gbl...

Quote:

Originally Posted by

>
Hi,
I am getting an error while trying to create an excel file.
"Description: The application attempted to perform an operation not
allowed by the security policy. To grant this application the required
permission please contact your system administrator or change the
application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Permission denied"
>
This is what I am doing. we had an app that was written in VB to take
specific dates and create an excel file.
I am using the dll in my .NET app but it displays the error while writing
the file...
>
I am sure that I have used regsrv32 to register the DLL
>
any suggestions,
Stephen
>


Hi Kumar and Nicole,

This is how I am working on this project. I have a DLL given to me by
another developer that generates Excel files and he created it using VB6.
I registered it on my box, referenced it and I am trying to use it
This is the error I am getting along with stack trace:

Description: The application attempted to perform an operation not allowed
by the security policy. To grant this application the required permission
please contact your system administrator or change the application's trust
level in the configuration file.

Exception Details: System.Security.SecurityException: Permission denied

[SecurityException: Permission denied]
CBAS_DTStoExcel.CBQueryDTStoExcelClass.set_OutPath (Object ) +0
cbas.QueryDB.ExportToExcel(DateTime dBeginDate, DateTime dEndDate) in
C:\Inetpub\wwwroot\CBAS_Deploy\QueryDB.aspx.vb:74
cbas.QueryDB.btnRunReport_Click(Object sender, EventArgs e) in
C:\Inetpub\wwwroot\CBAS_Deploy\QueryDB.aspx.vb:53
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +2112
System.Web.UI.Page.ProcessRequest() +217
System.Web.UI.Page.ProcessRequest(HttpContext context) +18
System.Web.CallHandlerExecutionStep.System.Web.Htt pApplication+IExecutionStep.Execute()
+179
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously) +87

"Kumar Reddi" <kumarreddi@.gmail.comwrote in message
news:1155062429.705709.30770@.h48g2000cwc.googlegro ups.com...

Quote:

Originally Posted by

you said you are using the COM server DLL directly in .net? If thats
what you are doing.. you need to create an interop assembly before you
can access the methods in that dll
>
Please let me know if I understoof your question incorrectly
>
stephen wrote:

Quote:

Originally Posted by

>Hi,
>I am getting an error while trying to create an excel file.
>"Description: The application attempted to perform an operation not
>allowed
>by the security policy. To grant this application the required permission
>please contact your system administrator or change the application's
>trust
>level in the configuration file.
>Exception Details: System.Security.SecurityException: Permission denied"
>>
>This is what I am doing. we had an app that was written in VB to take
>specific dates and create an excel file.
>I am using the dll in my .NET app but it displays the error while writing
>the file...
>>
>I am sure that I have used regsrv32 to register the DLL
>>
>any suggestions,
>Stephen


>


It looks like your ASP.NET application is not probably not running with
unrestricted CAS permissions (aka full trust). Unless you have restricted
CAS permissions via your own application's web.config file, adjusting this
is a task for the server administrator. (If you are in shared hosting, it's
likely that the administrator will be unwilling to increase your
application's permissions, and you may need to move to dedicated hosting.)

"stephen" <stephen_jn@.hotmail.comwrote in message
news:%23DomAH0uGHA.5044@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

Hi Kumar and Nicole,
>
This is how I am working on this project. I have a DLL given to me by
another developer that generates Excel files and he created it using VB6.
I registered it on my box, referenced it and I am trying to use it
This is the error I am getting along with stack trace:
>
Description: The application attempted to perform an operation not allowed
by the security policy. To grant this application the required permission
please contact your system administrator or change the application's trust
level in the configuration file.
>
Exception Details: System.Security.SecurityException: Permission denied
>
>
[SecurityException: Permission denied]
CBAS_DTStoExcel.CBQueryDTStoExcelClass.set_OutPath (Object ) +0
cbas.QueryDB.ExportToExcel(DateTime dBeginDate, DateTime dEndDate) in
C:\Inetpub\wwwroot\CBAS_Deploy\QueryDB.aspx.vb:74
cbas.QueryDB.btnRunReport_Click(Object sender, EventArgs e) in
C:\Inetpub\wwwroot\CBAS_Deploy\QueryDB.aspx.vb:53
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
>
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +2112
System.Web.UI.Page.ProcessRequest() +217
System.Web.UI.Page.ProcessRequest(HttpContext context) +18
>
System.Web.CallHandlerExecutionStep.System.Web.Htt pApplication+IExecutionStep.Execute()
+179
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously) +87
>
>
>
>
>
>
"Kumar Reddi" <kumarreddi@.gmail.comwrote in message
news:1155062429.705709.30770@.h48g2000cwc.googlegro ups.com...

Quote:

Originally Posted by

>you said you are using the COM server DLL directly in .net? If thats
>what you are doing.. you need to create an interop assembly before you
>can access the methods in that dll
>>
>Please let me know if I understoof your question incorrectly
>>
>stephen wrote:

Quote:

Originally Posted by

>>Hi,
>>I am getting an error while trying to create an excel file.
>>"Description: The application attempted to perform an operation not
>>allowed
>>by the security policy. To grant this application the required
>>permission
>>please contact your system administrator or change the application's
>>trust
>>level in the configuration file.
>>Exception Details: System.Security.SecurityException: Permission denied"
>>>
>>This is what I am doing. we had an app that was written in VB to take
>>specific dates and create an excel file.
>>I am using the dll in my .NET app but it displays the error while
>>writing
>>the file...
>>>
>>I am sure that I have used regsrv32 to register the DLL
>>>
>>any suggestions,
>>Stephen


>>


>
>