Showing posts with label created. Show all posts
Showing posts with label created. Show all posts

Saturday, March 31, 2012

Theming custom created WebParts in ASP.NET 2.0

I have created my own WebPart using code, it is not derived from a UserControl.
Inside this WebPart I create a Calendar Control and add it to the WebParts
Control collection.

Now I want to apply a theme to this Calendar that is inside my WebPart. How
do I do that? I have created a theme and added a definition for a calendar.
The theme is applied to a calendar that is not inside the WebPart, but it is
not applied to the one inside.Hi c_kimbell,

Welcome to MSDN newsgroup.
As for the custom WebPart with a Calendar inside it, is it possible that we
define a public property on the Custom webPart which represent the Theme of
the inside Calendar control? Then, we any one assign a new value for this
property, the nested calendar's Theme value will be changed accordingly.

In addition, for .NET 2.0 and VS.NET whidbey beta issues, I suggest you
also try posting in the following web forum:

http://forums.microsoft.com/msdn/

since there are some other experienced members who may have some good ideas.

Thank you,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Thanks for suggesting the ASP.NET forums, I have posted there now as well.

Here are some more details on what I have tried;
1. On the webpart I have exposed the Calendar as a property with the name
FromCalendar.
2. I have added the following to the .skin file

<%@. Register Assembly="IMK.WebParts" Namespace="IMK.WebParts"
TagPrefix="IMK" %
<IMK:IMKDateWebPart runat="server">
<FromCalendar BackColor="#FFFFCC">
<SelectedDayStyle BackColor="#CCCCFF" Font-Bold="True" />
<TitleStyle BackColor="#990000" Font-Bold="True" Font-Size="9pt"
ForeColor="#FFFFCC" />
</FromCalendar>
</IMK:IMKDateWebPart
Am I on the right track?

"Steven Cheng[MSFT]" wrote:

> Hi c_kimbell,
> Welcome to MSDN newsgroup.
> As for the custom WebPart with a Calendar inside it, is it possible that we
> define a public property on the Custom webPart which represent the Theme of
> the inside Calendar control? Then, we any one assign a new value for this
> property, the nested calendar's Theme value will be changed accordingly.
> In addition, for .NET 2.0 and VS.NET whidbey beta issues, I suggest you
> also try posting in the following web forum:
> http://forums.microsoft.com/msdn/
> since there are some other experienced members who may have some good ideas.
> Thank you,
> Steven Cheng
> Microsoft Online Support
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
Hi c_kimbell,

Thanks for your followup.
As you mentioned that
=================

1. On the webpart I have exposed the Calendar as a property with the name
FromCalendar.
2. I have added the following to the .skin file

<%@. Register Assembly="IMK.WebParts" Namespace="IMK.WebParts"
TagPrefix="IMK" %
<IMK:IMKDateWebPart runat="server">
<FromCalendar BackColor="#FFFFCC">
<SelectedDayStyle BackColor="#CCCCFF" Font-Bold="True" />
<TitleStyle BackColor="#990000" Font-Bold="True" Font-Size="9pt"
ForeColor="#FFFFCC" />
</FromCalendar>
</IMK:IMKDateWebPart>
=======================

I'm not sure whether this will cause error since I haven't tested it.
However, IMO, I'd prefer expose a single string property on my custom web
control which represent the nested child calendar's Theme(or
stylesheettheme). Since the ASP.NET 2.0 's Theme are mostly for those
simple type properteis (such as string, int), I think just exposing a
single string type property will be much better). You can do the actual
Theme adjusting in the Property's Setter method.
How do you think ?

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
I get your point about using simple strings. One thing though, say you expose
a color, this can be specified using a name like 'Red' or it may be specified
using hex notation, like '#FFCC66'. The controls require a Color object, how
does one map between the different representations and the Color object. Are
there any utility classes I can use?

I have now done a bit more experimenting. If I declaratively add the webpart
to a webpartzone, then the theme is correctly applied. If I add the same
webpart to the zone using a catalog, the style is not applied. The catalog
I'm adding from is a custom created one, not one of the predefined types.

Any suggestions?

"Steven Cheng[MSFT]" wrote:

> Hi c_kimbell,
> Thanks for your followup.
> As you mentioned that
> =================
>
> 1. On the webpart I have exposed the Calendar as a property with the name
> FromCalendar.
> 2. I have added the following to the .skin file
> <%@. Register Assembly="IMK.WebParts" Namespace="IMK.WebParts"
> TagPrefix="IMK" %>
> <IMK:IMKDateWebPart runat="server">
> <FromCalendar BackColor="#FFFFCC">
> <SelectedDayStyle BackColor="#CCCCFF" Font-Bold="True" />
> <TitleStyle BackColor="#990000" Font-Bold="True" Font-Size="9pt"
> ForeColor="#FFFFCC" />
> </FromCalendar>
> </IMK:IMKDateWebPart>
> =======================
> I'm not sure whether this will cause error since I haven't tested it.
> However, IMO, I'd prefer expose a single string property on my custom web
> control which represent the nested child calendar's Theme(or
> stylesheettheme). Since the ASP.NET 2.0 's Theme are mostly for those
> simple type properteis (such as string, int), I think just exposing a
> single string type property will be much better). You can do the actual
> Theme adjusting in the Property's Setter method.
> How do you think ?
> Steven Cheng
> Microsoft Online Support
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
Hi c_kimbell,

For those Color field, the ASP.NET runtime's ControlParser will help parse
the property value into the correct object instance. And for Color, there
is the ColorTranslator class which can be used from convert string color
value to System.Drawing.Color instance. For example:

string htmlColor = "Blue";
//or string htmlColor = "#3344ee";
// Translate htmlColor to a GDI+ Color structure.
Color myColor = ColorTranslator.FromHtml(htmlColor);

For the applying theme for custom created catalog's webpart, I'm not sure
whether this is ok. As far as I know, since the ASP.NET2.0 runtime apply
theme for controls in the page's PreInit event, so any change on Theme
after that event (for example in Page_load ..., post back event) will not
work in the first loading...

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

There is a problem with your selected data store

Hi,
I am using SQLServer 2005.I have created a simple website and i am trying
to membership to this.so when i click on 'Security' tab of the "WAT" tool it
s
showing the following message.
There is a problem with your selected data store. This can be caused by an
invalid server name or credentials, or by insufficient permission. It can
also be caused by the role manager feature not being enabled. Click the
button below to be redirected to a page where you can choose a new data stor
e.
The following message may help in diagnosing the problem: Unable to connect
to SQL Server database.
Is there anyway out of this?
Pls pls pull me out of this.
Regards,
SSREDDI.I had faced the same prob. but am not able to do that
this link helped me a little but. may be this may help u better.
http://www.c-sharpcorner.com/Upload...hipService.aspx
Hi Sravan,
Thank you for the information.I already tried this.I know this
works.My concern is that i dont want to use aspnet_regsql.exe.Anyway thanks
for the info.
"sravan_reddy001" wrote:

> I had faced the same prob. but am not able to do that
> this link helped me a little but. may be this may help u better.
> http://www.c-sharpcorner.com/Upload...hipService.aspx
>
u try editing the web.config file...
there is lot more to do with that..
hav u created ur own database for your application. If so you have to
give the connection string for that database.
This is my webconfig file. see this and try. I tried for about 3 days
to that.
if u didn't include the roleManager then we can't create the roles and
it states and error message saying "website not configured to enable
roles"
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/
v2.0">
<appSettings/>
<connectionStrings>
<add name="MySqlProviderConnection"
connectionString="server=localhost;integrated security =
true;database=aspnetdb" />
</connectionStrings>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true"/>
<authorization>
<deny users="?"/>
</authorization>
<membership defaultProvider="MySqlMembershipProvider">
<providers>
<add connectionStringName="MySqlProviderConnection"
enablePasswordRetrieval="false"
enablePasswordReset="true" requiresQuestionAndAnswer="true"
applicationName="/" requiresUniqueEmail="true"
maxInvalidPasswordAttempts="5"
passwordAttemptWindow="10" name="MySqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0" />
</providers>
</membership>
<roleManager enabled="true" defaultProvider="SqlRoleProvider">
<providers>
<clear />
<add applicationName="MyAppName"
connectionStringName="MySqlProviderConnection"
name="SqlRoleProvider"
type="System.Web.Security.SqlRoleProvider" />
</providers>
</roleManager>
quote:
Originally posted by ssreddi
Hi,
I am using SQLServer 2005.I have created a simple website and i am trying
to membership to this.so when i click on 'Security' tab of the "WAT" tool it
s
showing the following message.
There is a problem with your selected data store. This can be caused by an
invalid server name or credentials, or by insufficient permission. It can
also be caused by the role manager feature not being enabled. Click the
button below to be redirected to a page where you can choose a new data stor
e.
The following message may help in diagnosing the problem: Unable to connect
to SQL Server database.
Is there anyway out of this?
Pls pls pull me out of this.
Regards,
SSREDDI.

There is a problem with your selected data store

Hi,
I am using SQLServer 2005.I have created a simple website and i am trying
to membership to this.so when i click on 'Security' tab of the "WAT" tool its
showing the following message.

There is a problem with your selected data store. This can be caused by an
invalid server name or credentials, or by insufficient permission. It can
also be caused by the role manager feature not being enabled. Click the
button below to be redirected to a page where you can choose a new data store.

The following message may help in diagnosing the problem: Unable to connect
to SQL Server database.

Is there anyway out of this?

Pls pls pull me out of this.

Regards,
SSREDDI.I had faced the same prob. but am not able to do that

this link helped me a little but. may be this may help u better.

http://www.c-sharpcorner.com/Upload...hipService.aspx
Hi Sravan,
Thank you for the information.I already tried this.I know this
works.My concern is that i dont want to use aspnet_regsql.exe.Anyway thanks
for the info.

"sravan_reddy001" wrote:

Quote:

Originally Posted by

I had faced the same prob. but am not able to do that
>
this link helped me a little but. may be this may help u better.
>
http://www.c-sharpcorner.com/Upload...hipService.aspx
>
>


u try editing the web.config file...

there is lot more to do with that..
hav u created ur own database for your application. If so you have to
give the connection string for that database.

This is my webconfig file. see this and try. I tried for about 3 days
to that.

if u didn't include the roleManager then we can't create the roles and
it states and error message saying "website not configured to enable
roles"

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/
v2.0">
<appSettings/>
<connectionStrings>
<add name="MySqlProviderConnection"
connectionString="server=localhost;integrated security =
true;database=aspnetdb" />
</connectionStrings>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true"/>
<authorization>
<deny users="?"/>
</authorization>
<membership defaultProvider="MySqlMembershipProvider">
<providers>
<add connectionStringName="MySqlProviderConnection"
enablePasswordRetrieval="false"
enablePasswordReset="true" requiresQuestionAndAnswer="true"
applicationName="/" requiresUniqueEmail="true"
maxInvalidPasswordAttempts="5"
passwordAttemptWindow="10" name="MySqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0" />
</providers>
</membership>

<roleManager enabled="true" defaultProvider="SqlRoleProvider">
<providers>
<clear />
<add applicationName="MyAppName"
connectionStringName="MySqlProviderConnection"
name="SqlRoleProvider"
type="System.Web.Security.SqlRoleProvider" />
</providers>
</roleManager>

There is no consumer connection point 'IMessageConsumer' on 'bla [2]'.

I created a static connected webpart.

INTERFACE:
public interface IMessage
{
string Message { get;}
}

USERCONTROL PROVIDER:
public partial class Control1 : System.Web.UI.UserControl, IMessage,
IWebPart
{
protected void Page_Load(object sender, EventArgs e)
{

}
[ConnectionProvider("Message","IMessageProvider")]
public IMessage GetMessage()
{
return this;
}
public string Message
{
get
{
return TextBox1.Text;
}
}

#region IWebPart Members (ETC)

USERCONTROL CONSUMER
public partial class Control2 : System.Web.UI.UserControl, IWebPart
{
protected void Page_Load(object sender, EventArgs e)
{

}

private IMessage _message;

[ConnectionConsumer("Message","IMessageConsumer",AllowsMultipleConnections=true)]
void SetMessage(IMessage message)
{
this._message = message;
}

protected override void OnPreRender(EventArgs e)
{
if (_message != null)
Label1.Text = _message.Message;
base.OnPreRender(e);
}
#region IWebPart Members (ETC)

DEFAULT.ASPX:

<body>
<form id="form1" runat="server">

<div>
<asp:WebPartManager ID="WebPartManager1" runat="server"
Personalization-Enabled="true">
<StaticConnections>
<asp:WebPartConnection ID="conId"
ConsumerID="dataConsumer" ProviderID="dataProvider"
ConsumerConnectionPointID="IMessageConsumer"
ProviderConnectionPointID="IMessageProvider" />
</StaticConnections>

</asp:WebPartManager>
<asp:WebPartZone ID="WebPartZone1" runat="server">
<ZoneTemplate>
<uc1:Control1 ID="dataProvider" runat="server" />
<uc2:Control2 ID="dataConsumer" runat="server" />
</ZoneTemplate>
</asp:WebPartZone>

</div>
</form>
</body>

And I get this error :"There is no consumer connection point
'IMessageConsumer' on 'bla [2]'. "... Checkded it with multiple
tutorials, but can't find what I'm doing wrong.

Hope someone can help me!
Regards,
PatrickUSERCONTROL CONSUMER

Quote:

Originally Posted by

public partial class Control2 : System.Web.UI.UserControl, IWebPart
{
protected void Page_Load(object sender, EventArgs e)
{
>
}
>
private IMessage _message;
>
[ConnectionConsumer("Message","IMessageConsumer",AllowsMultipleConnections=*true)]
void SetMessage(IMessage message)
{
this._message = message;
}
>


Solved it, I forgot to make the SetMessage public ;-)

There is no consumer connection point 'IMessageConsumer' on 'bla '.

I created a static connected webpart.
INTERFACE:
public interface IMessage
{
string Message { get;}
}
USERCONTROL PROVIDER:
public partial class Control1 : System.Web.UI.UserControl, IMessage,
IWebPart
{
protected void Page_Load(object sender, EventArgs e)
{
}
[ConnectionProvider("Message","IMessageProvider")]
public IMessage GetMessage()
{
return this;
}
public string Message
{
get
{
return TextBox1.Text;
}
}
#region IWebPart Members (ETC)
USERCONTROL CONSUMER
public partial class Control2 : System.Web.UI.UserControl, IWebPart
{
protected void Page_Load(object sender, EventArgs e)
{
}
private IMessage _message;
[ConnectionConsumer("Message","IMessageConsumer",AllowsMultipleConnections=t
rue)]
void SetMessage(IMessage message)
{
this._message = message;
}
protected override void OnPreRender(EventArgs e)
{
if (_message != null)
Label1.Text = _message.Message;
base.OnPreRender(e);
}
#region IWebPart Members (ETC)
DEFAULT.ASPX:
<body>
<form id="form1" runat="server">
<div>
<asp:WebPartManager ID="WebPartManager1" runat="server"
Personalization-Enabled="true">
<StaticConnections>
<asp:WebPartConnection ID="conId"
ConsumerID="dataConsumer" ProviderID="dataProvider"
ConsumerConnectionPointID="IMessageConsumer"
ProviderConnectionPointID="IMessageProvider" />
</StaticConnections>
</asp:WebPartManager>
<asp:WebPartZone ID="WebPartZone1" runat="server">
<ZoneTemplate>
<uc1:Control1 ID="dataProvider" runat="server" />
<uc2:Control2 ID="dataConsumer" runat="server" />
</ZoneTemplate>
</asp:WebPartZone>
</div>
</form>
</body>
And I get this error :"There is no consumer connection point
'IMessageConsumer' on 'bla [2]'. "... Checkded it with multiple
tutorials, but can't find what I'm doing wrong.
Hope someone can help me!
Regards,
Patrick> USERCONTROL CONSUMER
> public partial class Control2 : System.Web.UI.UserControl, IWebPart
> {
> protected void Page_Load(object sender, EventArgs e)
> {
> }
> private IMessage _message;
> [ConnectionConsumer("Message","IMessageConsumer",AllowsMultipleConnection=
s=3D=ADtrue)]
> void SetMessage(IMessage message)
> {
> this._message =3D message;
> }
>
Solved it, I forgot to make the SetMessage public ;-)

Wednesday, March 28, 2012

This code crashes, what am I doing wrong??

ASP.NET 2.0

This code crashes. It generate this error:
Value cannot be null.
Parameter name: type

I've created some custom web.config settings and this crash is related to
accessing theme custom settings. This code is where the crash occur:
_instance =
(DAL)Activator.CreateInstance(Type.GetType(min.tes t.Config.Settings.msgElement.ProviderType));
This code is trying to do is to create an instance of the DAL provider,

************* custom web.config settings: **********************
<configSections>
<section name="msg" type="min.test.ConfigSection, __code"/>
</configSections>
<msg>
<messages providerType="min.test.DAL.SqlServer2005"/>
</msg>

********* In this code the crash occur *********
/* This code is from the DAL class, this code is trying to create an
instance of the DAL set in web.config - min.test.DAL.SqlServer2005
static public DAL Instance
{
get
{
if (_instance == null)
_instance =
(DAL)Activator.CreateInstance(Type.GetType(min.tes t.Config.Settings.msgElement.ProviderType));
<-- code crashes here
return _instance;
}
}

******** definition of the custom settings in web.config
**********************
using System;
using System.Collections.Generic;
using System.Configuration;

namespace min.test
{
public class ConfigSection : ConfigurationSection
{
[ConfigurationProperty("messages", IsRequired = true)]
public MsgElement msgElement
{
get { return (MsgElement)base["messages"]; }
}

}

public class MsgElement : ConfigurationElement
{
[ConfigurationProperty("providerType", DefaultValue =
"min.test.DAL.SqlServer2005")]
public string ProviderType
{
get { return (string)base["providerType"]; }
set { base["providerType"] = value; }
}
}

}

Any suggestions??

JeffWell,
The exception message doesn't lie - it's telling you that you've got a null
value, and it cannot accept it and continue.

One way to get at this is to "take apart" your compound statement so that it
will becom easier to set breakpoints and examine values, e.g.:

instance =
(DAL)Activator.CreateInstance(Type.GetType(min.tes t.Config.Settings.msgElement.ProviderType));

could be:

Type t = Type.GetType(min.test.Config.Settings.msgElement.P roviderType);
// check to see if t above is null.

instance = (DAL)Activator.CreateInstance(t);

Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"Jeff" wrote:

Quote:

Originally Posted by

ASP.NET 2.0
>
This code crashes. It generate this error:
Value cannot be null.
Parameter name: type
>
I've created some custom web.config settings and this crash is related to
accessing theme custom settings. This code is where the crash occur:
_instance =
(DAL)Activator.CreateInstance(Type.GetType(min.tes t.Config.Settings.msgElement.ProviderType));
This code is trying to do is to create an instance of the DAL provider,
>
************* custom web.config settings: **********************
<configSections>
<section name="msg" type="min.test.ConfigSection, __code"/>
</configSections>
<msg>
<messages providerType="min.test.DAL.SqlServer2005"/>
</msg>
>
********* In this code the crash occur *********
/* This code is from the DAL class, this code is trying to create an
instance of the DAL set in web.config - min.test.DAL.SqlServer2005
static public DAL Instance
{
get
{
if (_instance == null)
_instance =
(DAL)Activator.CreateInstance(Type.GetType(min.tes t.Config.Settings.msgElement.ProviderType));
<-- code crashes here
return _instance;
}
}
>
******** definition of the custom settings in web.config
**********************
using System;
using System.Collections.Generic;
using System.Configuration;
>
namespace min.test
{
public class ConfigSection : ConfigurationSection
{
[ConfigurationProperty("messages", IsRequired = true)]
public MsgElement msgElement
{
get { return (MsgElement)base["messages"]; }
}
>
}
>
public class MsgElement : ConfigurationElement
{
[ConfigurationProperty("providerType", DefaultValue =
"min.test.DAL.SqlServer2005")]
public string ProviderType
{
get { return (string)base["providerType"]; }
set { base["providerType"] = value; }
}
}
>
}
>
Any suggestions??
>
Jeff
>
>
>


Thanks

Type t = Type.GetType(min.test.Config.Settings.msgElement.P roviderType);
t gets a NULL value here. I've looked at the web.config settings and the
code that creates the custom web.config settings and I cannot see what I'm
doing wrong here... or maybe I'm becoming blind to my own programming
errors. Do you see why it get NULL value??

Jeff

"Peter Bromberg [C# MVP]" <pbromberg@.yahoo.yabbadabbadoo.comwrote in
message news:ACE60486-118C-4BB2-A1C1-EB2416FB1CED@.microsoft.com...

Quote:

Originally Posted by

Well,
The exception message doesn't lie - it's telling you that you've got a
null
value, and it cannot accept it and continue.
>
One way to get at this is to "take apart" your compound statement so that
it
will becom easier to set breakpoints and examine values, e.g.:
>
instance =
(DAL)Activator.CreateInstance(Type.GetType(min.tes t.Config.Settings.msgElement.ProviderType));
>
could be:
>
Type t = Type.GetType(min.test.Config.Settings.msgElement.P roviderType);
// check to see if t above is null.
>
instance = (DAL)Activator.CreateInstance(t);
>
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
>
>
>
>
"Jeff" wrote:
>

Quote:

Originally Posted by

>ASP.NET 2.0
>>
>This code crashes. It generate this error:
>Value cannot be null.
>Parameter name: type
>>
>I've created some custom web.config settings and this crash is related to
>accessing theme custom settings. This code is where the crash occur:
>_instance =
>(DAL)Activator.CreateInstance(Type.GetType(min.tes t.Config.Settings.msgElement.ProviderType));
>This code is trying to do is to create an instance of the DAL provider,
>>
>************* custom web.config settings: **********************
><configSections>
> <section name="msg" type="min.test.ConfigSection, __code"/>
></configSections>
><msg>
> <messages providerType="min.test.DAL.SqlServer2005"/>
></msg>
>>
>********* In this code the crash occur *********
>/* This code is from the DAL class, this code is trying to create an
>instance of the DAL set in web.config - min.test.DAL.SqlServer2005
>static public DAL Instance
>{
> get
> {
> if (_instance == null)
> _instance =
>(DAL)Activator.CreateInstance(Type.GetType(min.tes t.Config.Settings.msgElement.ProviderType));
><-- code crashes here
> return _instance;
> }
>}
>>
>******** definition of the custom settings in web.config
>**********************
>using System;
>using System.Collections.Generic;
>using System.Configuration;
>>
>namespace min.test
>{
> public class ConfigSection : ConfigurationSection
> {
> [ConfigurationProperty("messages", IsRequired = true)]
> public MsgElement msgElement
> {
> get { return (MsgElement)base["messages"]; }
> }
>>
> }
>>
> public class MsgElement : ConfigurationElement
> {
> [ConfigurationProperty("providerType", DefaultValue =
>"min.test.DAL.SqlServer2005")]
> public string ProviderType
> {
> get { return (string)base["providerType"]; }
> set { base["providerType"] = value; }
> }
> }
>>
>}
>>
>Any suggestions??
>>
>Jeff
>>
>>
>>


Type.GetType gives you the ability to get a type back from a string. You pass
a known, available type name string to it, and expect it return that type.

If the assembly name is specified in the typeName string, Type.GetType()
will search inside this assembly only; otherwise, it tries to find one in the
caller assembly and then the system assembly (mscorlib.dll). Anything after
',' in the typeName string is treated as assembly name. To make it work,you
need to specify "YourAssembly.dll" in typeName. In contrast,
Type.GetType("System.Int32") can return type System.Int32 without mentioning
"mscorlib.dll".

Type.AssemblyQualifiedName is the right way to tell what kind of typeName
you should provide.
typeof(System.Data.SqlClient.SqlException).Assembl yQualifiedName equals:
"System.Data.SqlClient.SqlException, System.Data, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089". Type.GetType with this
long string will succeed in .NET 2.0.

In .NET, namespace and the associated assembly name are not necessarily
related. Type "System.Data.SqlClient.SqlException" is not associated with
"System.Data.SqlClient.dll" (which does not exist).

-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"Jeff" wrote:

Quote:

Originally Posted by

Thanks
>
Type t = Type.GetType(min.test.Config.Settings.msgElement.P roviderType);
t gets a NULL value here. I've looked at the web.config settings and the
code that creates the custom web.config settings and I cannot see what I'm
doing wrong here... or maybe I'm becoming blind to my own programming
errors. Do you see why it get NULL value??
>
Jeff
>
"Peter Bromberg [C# MVP]" <pbromberg@.yahoo.yabbadabbadoo.comwrote in
message news:ACE60486-118C-4BB2-A1C1-EB2416FB1CED@.microsoft.com...

Quote:

Originally Posted by

Well,
The exception message doesn't lie - it's telling you that you've got a
null
value, and it cannot accept it and continue.

One way to get at this is to "take apart" your compound statement so that
it
will becom easier to set breakpoints and examine values, e.g.:

instance =
(DAL)Activator.CreateInstance(Type.GetType(min.tes t.Config.Settings.msgElement.ProviderType));

could be:

Type t = Type.GetType(min.test.Config.Settings.msgElement.P roviderType);
// check to see if t above is null.

instance = (DAL)Activator.CreateInstance(t);

Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"Jeff" wrote:

Quote:

Originally Posted by

ASP.NET 2.0
>
This code crashes. It generate this error:
Value cannot be null.
Parameter name: type
>
I've created some custom web.config settings and this crash is related to
accessing theme custom settings. This code is where the crash occur:
_instance =
(DAL)Activator.CreateInstance(Type.GetType(min.tes t.Config.Settings.msgElement.ProviderType));
This code is trying to do is to create an instance of the DAL provider,
>
************* custom web.config settings: **********************
<configSections>
<section name="msg" type="min.test.ConfigSection, __code"/>
</configSections>
<msg>
<messages providerType="min.test.DAL.SqlServer2005"/>
</msg>
>
********* In this code the crash occur *********
/* This code is from the DAL class, this code is trying to create an
instance of the DAL set in web.config - min.test.DAL.SqlServer2005
static public DAL Instance
{
get
{
if (_instance == null)
_instance =
(DAL)Activator.CreateInstance(Type.GetType(min.tes t.Config.Settings.msgElement.ProviderType));
<-- code crashes here
return _instance;
}
}
>
******** definition of the custom settings in web.config
**********************
using System;
using System.Collections.Generic;
using System.Configuration;
>
namespace min.test
{
public class ConfigSection : ConfigurationSection
{
[ConfigurationProperty("messages", IsRequired = true)]
public MsgElement msgElement
{
get { return (MsgElement)base["messages"]; }
}
>
}
>
public class MsgElement : ConfigurationElement
{
[ConfigurationProperty("providerType", DefaultValue =
"min.test.DAL.SqlServer2005")]
public string ProviderType
{
get { return (string)base["providerType"]; }
set { base["providerType"] = value; }
}
}
>
}
>
Any suggestions??
>
Jeff
>
>
>


>
>
>


Jeff,

In addition to Peter's reply, there's another way of obtaining the reference
in ASP.NET 2.0 dynamic compilation enviroment. Please use
System.Web.Compilation.BuildManager.GetType(min.te st.Config.Settings.msgElement.ProviderType, true);
instead.

Regards
--
Milosz

"Peter Bromberg [C# MVP]" wrote:

Quote:

Originally Posted by

Type.GetType gives you the ability to get a type back from a string. You pass
a known, available type name string to it, and expect it return that type.
>
If the assembly name is specified in the typeName string, Type.GetType()
will search inside this assembly only; otherwise, it tries to find one in the
caller assembly and then the system assembly (mscorlib.dll). Anything after
',' in the typeName string is treated as assembly name. To make it work,you
need to specify "YourAssembly.dll" in typeName. In contrast,
Type.GetType("System.Int32") can return type System.Int32 without mentioning
"mscorlib.dll".
>
Type.AssemblyQualifiedName is the right way to tell what kind of typeName
you should provide.
typeof(System.Data.SqlClient.SqlException).Assembl yQualifiedName equals:
"System.Data.SqlClient.SqlException, System.Data, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089". Type.GetType with this
long string will succeed in .NET 2.0.
>
In .NET, namespace and the associated assembly name are not necessarily
related. Type "System.Data.SqlClient.SqlException" is not associated with
"System.Data.SqlClient.dll" (which does not exist).
>
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
>
>
>
>
"Jeff" wrote:
>

Quote:

Originally Posted by

Thanks

Type t = Type.GetType(min.test.Config.Settings.msgElement.P roviderType);
t gets a NULL value here. I've looked at the web.config settings and the
code that creates the custom web.config settings and I cannot see what I'm
doing wrong here... or maybe I'm becoming blind to my own programming
errors. Do you see why it get NULL value??

Jeff

"Peter Bromberg [C# MVP]" <pbromberg@.yahoo.yabbadabbadoo.comwrote in
message news:ACE60486-118C-4BB2-A1C1-EB2416FB1CED@.microsoft.com...

Quote:

Originally Posted by

Well,
The exception message doesn't lie - it's telling you that you've got a
null
value, and it cannot accept it and continue.
>
One way to get at this is to "take apart" your compound statement so that
it
will becom easier to set breakpoints and examine values, e.g.:
>
instance =
(DAL)Activator.CreateInstance(Type.GetType(min.tes t.Config.Settings.msgElement.ProviderType));
>
could be:
>
Type t = Type.GetType(min.test.Config.Settings.msgElement.P roviderType);
// check to see if t above is null.
>
instance = (DAL)Activator.CreateInstance(t);
>
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
>
>
>
>
"Jeff" wrote:
>
>ASP.NET 2.0
>>
>This code crashes. It generate this error:
>Value cannot be null.
>Parameter name: type
>>
>I've created some custom web.config settings and this crash is related to
>accessing theme custom settings. This code is where the crash occur:
>_instance =
>(DAL)Activator.CreateInstance(Type.GetType(min.tes t.Config.Settings.msgElement.ProviderType));
>This code is trying to do is to create an instance of the DAL provider,
>>
>************* custom web.config settings: **********************
><configSections>
> <section name="msg" type="min.test.ConfigSection, __code"/>
></configSections>
><msg>
> <messages providerType="min.test.DAL.SqlServer2005"/>
></msg>
>>
>********* In this code the crash occur *********
>/* This code is from the DAL class, this code is trying to create an
>instance of the DAL set in web.config - min.test.DAL.SqlServer2005
>static public DAL Instance
>{
> get
> {
> if (_instance == null)
> _instance =
>(DAL)Activator.CreateInstance(Type.GetType(min.tes t.Config.Settings.msgElement.ProviderType));
><-- code crashes here
> return _instance;
> }
>}
>>
>******** definition of the custom settings in web.config
>**********************
>using System;
>using System.Collections.Generic;
>using System.Configuration;
>>
>namespace min.test
>{
> public class ConfigSection : ConfigurationSection
> {
> [ConfigurationProperty("messages", IsRequired = true)]
> public MsgElement msgElement
> {
> get { return (MsgElement)base["messages"]; }
> }
>>
> }
>>
> public class MsgElement : ConfigurationElement
> {
> [ConfigurationProperty("providerType", DefaultValue =
>"min.test.DAL.SqlServer2005")]
> public string ProviderType
> {
> get { return (string)base["providerType"]; }
> set { base["providerType"] = value; }
> }
> }
>>
>}
>>
>Any suggestions??
>>
>Jeff
>>
>>
>>



thank you guys, you helped me solve this problem.

This is a bit embarrassing. I tryed to create an instance of this class:
min.test.DAL.SqlServer2005, but this class don't exist in my project.
min.test.DAL.SqlServer2005.SqlServer2005 is the class I needed... I had
forgot that I had a namespace with the same name as the class...
anyway I changed the .SqlServer2005 namespace to SqlClient so now I'm
accessing min.test.DAL.SqlClient.SqlServer2005

once again, thank you

cheers

Jeff

"Milosz Skalecki [MCAD]" <mily242@.DONTLIKESPAMwp.plwrote in message
news:FB62B8F3-8DAE-4E81-917C-935316F2CFE8@.microsoft.com...

Quote:

Originally Posted by

Jeff,
>
In addition to Peter's reply, there's another way of obtaining the
reference
in ASP.NET 2.0 dynamic compilation enviroment. Please use
System.Web.Compilation.BuildManager.GetType(min.te st.Config.Settings.msgElement.ProviderType,
true);
instead.
>
Regards
--
Milosz
>
>
"Peter Bromberg [C# MVP]" wrote:
>

Quote:

Originally Posted by

>Type.GetType gives you the ability to get a type back from a string. You
>pass
>a known, available type name string to it, and expect it return that
>type.
>>
>If the assembly name is specified in the typeName string, Type.GetType()
>will search inside this assembly only; otherwise, it tries to find one in
>the
>caller assembly and then the system assembly (mscorlib.dll). Anything
>after
>',' in the typeName string is treated as assembly name. To make it
>work,you
>need to specify "YourAssembly.dll" in typeName. In contrast,
>Type.GetType("System.Int32") can return type System.Int32 without
>mentioning
>"mscorlib.dll".
>>
>Type.AssemblyQualifiedName is the right way to tell what kind of typeName
>you should provide.
>typeof(System.Data.SqlClient.SqlException).Assembl yQualifiedName equals:
>"System.Data.SqlClient.SqlException, System.Data, Version=2.0.0.0,
>Culture=neutral, PublicKeyToken=b77a5c561934e089". Type.GetType with this
>long string will succeed in .NET 2.0.
>>
>In .NET, namespace and the associated assembly name are not necessarily
>related. Type "System.Data.SqlClient.SqlException" is not associated with
>"System.Data.SqlClient.dll" (which does not exist).
>>
>-- Peter
>Site: http://www.eggheadcafe.com
>UnBlog: http://petesbloggerama.blogspot.com
>Short urls & more: http://ittyurl.net
>>
>>
>>
>>
>"Jeff" wrote:
>>

Quote:

Originally Posted by

Thanks
>
Type t =
Type.GetType(min.test.Config.Settings.msgElement.P roviderType);
t gets a NULL value here. I've looked at the web.config settings and
the
code that creates the custom web.config settings and I cannot see what
I'm
doing wrong here... or maybe I'm becoming blind to my own programming
errors. Do you see why it get NULL value??
>
Jeff
>
"Peter Bromberg [C# MVP]" <pbromberg@.yahoo.yabbadabbadoo.comwrote in
message news:ACE60486-118C-4BB2-A1C1-EB2416FB1CED@.microsoft.com...
Well,
The exception message doesn't lie - it's telling you that you've got
a
null
value, and it cannot accept it and continue.
>
One way to get at this is to "take apart" your compound statement so
that
it
will becom easier to set breakpoints and examine values, e.g.:
>
instance =
(DAL)Activator.CreateInstance(Type.GetType(min.tes t.Config.Settings.msgElement.ProviderType));
>
could be:
>
Type t =
Type.GetType(min.test.Config.Settings.msgElement.P roviderType);
// check to see if t above is null.
>
instance = (DAL)Activator.CreateInstance(t);
>
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
>
>
>
>
"Jeff" wrote:
>
>ASP.NET 2.0
>>
>This code crashes. It generate this error:
>Value cannot be null.
>Parameter name: type
>>
>I've created some custom web.config settings and this crash is
>related to
>accessing theme custom settings. This code is where the crash occur:
>_instance =
>(DAL)Activator.CreateInstance(Type.GetType(min.tes t.Config.Settings.msgElement.ProviderType));
>This code is trying to do is to create an instance of the DAL
>provider,
>>
>************* custom web.config settings: **********************
><configSections>
> <section name="msg" type="min.test.ConfigSection, __code"/>
></configSections>
><msg>
> <messages providerType="min.test.DAL.SqlServer2005"/>
></msg>
>>
>********* In this code the crash occur *********
>/* This code is from the DAL class, this code is trying to create an
>instance of the DAL set in web.config - min.test.DAL.SqlServer2005
>static public DAL Instance
>{
> get
> {
> if (_instance == null)
> _instance =
>(DAL)Activator.CreateInstance(Type.GetType(min.tes t.Config.Settings.msgElement.ProviderType));
><-- code crashes here
> return _instance;
> }
>}
>>
>******** definition of the custom settings in web.config
>**********************
>using System;
>using System.Collections.Generic;
>using System.Configuration;
>>
>namespace min.test
>{
> public class ConfigSection : ConfigurationSection
> {
> [ConfigurationProperty("messages", IsRequired = true)]
> public MsgElement msgElement
> {
> get { return (MsgElement)base["messages"]; }
> }
>>
> }
>>
> public class MsgElement : ConfigurationElement
> {
> [ConfigurationProperty("providerType", DefaultValue =
>"min.test.DAL.SqlServer2005")]
> public string ProviderType
> {
> get { return (string)base["providerType"]; }
> set { base["providerType"] = value; }
> }
> }
>>
>}
>>
>Any suggestions??
>>
>Jeff
>>
>>
>>
>
>
>

This code crashes, what am I doing wrong??

ASP.NET 2.0
This code crashes. It generate this error:
Value cannot be null.
Parameter name: type
I've created some custom web.config settings and this crash is related to
accessing theme custom settings. This code is where the crash occur:
_instance =
(DAL)Activator.CreateInstance(Type.GetType(min.test.Config.Settings.msgEleme
nt.ProviderType));
This code is trying to do is to create an instance of the DAL provider,
************* custom web.config settings: **********************
<configSections>
<section name="msg" type="min.test.ConfigSection, __code"/>
</configSections>
<msg>
<messages providerType="min.test.DAL.SqlServer2005"/>
</msg>
********* In this code the crash occur *********
/* This code is from the DAL class, this code is trying to create an
instance of the DAL set in web.config - min.test.DAL.SqlServer2005
static public DAL Instance
{
get
{
if (_instance == null)
_instance =
(DAL)Activator.CreateInstance(Type.GetType(min.test.Config.Settings.msgEleme
nt.ProviderType));
<-- code crashes here
return _instance;
}
}
******** definition of the custom settings in web.config
**********************
using System;
using System.Collections.Generic;
using System.Configuration;
namespace min.test
{
public class ConfigSection : ConfigurationSection
{
[ConfigurationProperty("messages", IsRequired = true)]
public MsgElement msgElement
{
get { return (MsgElement)base["messages"]; }
}
}
public class MsgElement : ConfigurationElement
{
[ConfigurationProperty("providerType", DefaultValue =
"min.test.DAL.SqlServer2005")]
public string ProviderType
{
get { return (string)base["providerType"]; }
set { base["providerType"] = value; }
}
}
}
Any suggestions'
JeffWell,
The exception message doesn't lie - it's telling you that you've got a null
value, and it cannot accept it and continue.
One way to get at this is to "take apart" your compound statement so that it
will becom easier to set breakpoints and examine values, e.g.:
instance =
(DAL)Activator.CreateInstance(Type.GetType(min.test.Config.Settings.msgEleme
nt.ProviderType));
could be:
Type t = Type.GetType(min.test.Config.Settings.msgElement.ProviderType);
// check to see if t above is null.
instance = (DAL)Activator.CreateInstance(t);
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"Jeff" wrote:

> ASP.NET 2.0
> This code crashes. It generate this error:
> Value cannot be null.
> Parameter name: type
> I've created some custom web.config settings and this crash is related to
> accessing theme custom settings. This code is where the crash occur:
> _instance =
> (DAL)Activator.CreateInstance(Type.GetType(min.test.Config.Settings.msgEle
ment.ProviderType));
> This code is trying to do is to create an instance of the DAL provider,
> ************* custom web.config settings: **********************
> <configSections>
> <section name="msg" type="min.test.ConfigSection, __code"/>
> </configSections>
> <msg>
> <messages providerType="min.test.DAL.SqlServer2005"/>
> </msg>
> ********* In this code the crash occur *********
> /* This code is from the DAL class, this code is trying to create an
> instance of the DAL set in web.config - min.test.DAL.SqlServer2005
> static public DAL Instance
> {
> get
> {
> if (_instance == null)
> _instance =
> (DAL)Activator.CreateInstance(Type.GetType(min.test.Config.Settings.msgEle
ment.ProviderType));
> <-- code crashes here
> return _instance;
> }
> }
> ******** definition of the custom settings in web.config
> **********************
> using System;
> using System.Collections.Generic;
> using System.Configuration;
> namespace min.test
> {
> public class ConfigSection : ConfigurationSection
> {
> [ConfigurationProperty("messages", IsRequired = true)]
> public MsgElement msgElement
> {
> get { return (MsgElement)base["messages"]; }
> }
> }
> public class MsgElement : ConfigurationElement
> {
> [ConfigurationProperty("providerType", DefaultValue =
> "min.test.DAL.SqlServer2005")]
> public string ProviderType
> {
> get { return (string)base["providerType"]; }
> set { base["providerType"] = value; }
> }
> }
> }
> Any suggestions'
> Jeff
>
>
Thanks
Type t = Type.GetType(min.test.Config.Settings.msgElement.ProviderType);
t gets a NULL value here. I've looked at the web.config settings and the
code that creates the custom web.config settings and I cannot see what I'm
doing wrong here... or maybe I'm becoming blind to my own programming
errors. Do you see why it get NULL value'
Jeff
"Peter Bromberg [C# MVP]" <pbromberg@.yahoo.yabbadabbadoo.com> wrote in
message news:ACE60486-118C-4BB2-A1C1-EB2416FB1CED@.microsoft.com...
> Well,
> The exception message doesn't lie - it's telling you that you've got a
> null
> value, and it cannot accept it and continue.
> One way to get at this is to "take apart" your compound statement so that
> it
> will becom easier to set breakpoints and examine values, e.g.:
> instance =
> (DAL)Activator.CreateInstance(Type.GetType(min.test.Config.Settings.msgEle
ment.ProviderType));
> could be:
> Type t = Type.GetType(min.test.Config.Settings.msgElement.ProviderType);
> // check to see if t above is null.
> instance = (DAL)Activator.CreateInstance(t);
> Peter
> --
> Site: http://www.eggheadcafe.com
> UnBlog: http://petesbloggerama.blogspot.com
> Short urls & more: http://ittyurl.net
>
>
> "Jeff" wrote:
>
Type.GetType gives you the ability to get a type back from a string. You pas
s
a known, available type name string to it, and expect it return that type.
If the assembly name is specified in the typeName string, Type.GetType()
will search inside this assembly only; otherwise, it tries to find one in th
e
caller assembly and then the system assembly (mscorlib.dll). Anything after
',' in the typeName string is treated as assembly name. To make it work,you
need to specify "YourAssembly.dll" in typeName. In contrast,
Type.GetType("System.Int32") can return type System.Int32 without mentioning
"mscorlib.dll".
Type.AssemblyQualifiedName is the right way to tell what kind of typeName
you should provide.
typeof(System.Data.SqlClient.SqlException).AssemblyQualifiedName equals:
"System.Data.SqlClient.SqlException, System.Data, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089". Type.GetType with this
long string will succeed in .NET 2.0.
In .NET, namespace and the associated assembly name are not necessarily
related. Type "System.Data.SqlClient.SqlException" is not associated with
"System.Data.SqlClient.dll" (which does not exist).
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"Jeff" wrote:

> Thanks
> Type t = Type.GetType(min.test.Config.Settings.msgElement.ProviderType);
> t gets a NULL value here. I've looked at the web.config settings and the
> code that creates the custom web.config settings and I cannot see what I'm
> doing wrong here... or maybe I'm becoming blind to my own programming
> errors. Do you see why it get NULL value'
> Jeff
> "Peter Bromberg [C# MVP]" <pbromberg@.yahoo.yabbadabbadoo.com> wrote in
> message news:ACE60486-118C-4BB2-A1C1-EB2416FB1CED@.microsoft.com...
>
>
Jeff,
In addition to Peter's reply, there's another way of obtaining the reference
in ASP.NET 2.0 dynamic compilation enviroment. Please use
System.Web.Compilation.BuildManager.GetType(min.test.Config.Settings.msgElem
ent.ProviderType, true);
instead.
Regards
--
Milosz
"Peter Bromberg [C# MVP]" wrote:
> Type.GetType gives you the ability to get a type back from a string. You p
ass
> a known, available type name string to it, and expect it return that type.
> If the assembly name is specified in the typeName string, Type.GetType()
> will search inside this assembly only; otherwise, it tries to find one in
the
> caller assembly and then the system assembly (mscorlib.dll). Anything afte
r
> ',' in the typeName string is treated as assembly name. To make it work,yo
u
> need to specify "YourAssembly.dll" in typeName. In contrast,
> Type.GetType("System.Int32") can return type System.Int32 without mentioni
ng
> "mscorlib.dll".
> Type.AssemblyQualifiedName is the right way to tell what kind of typeName
> you should provide.
> typeof(System.Data.SqlClient.SqlException).AssemblyQualifiedName equals:
> "System.Data.SqlClient.SqlException, System.Data, Version=2.0.0.0,
> Culture=neutral, PublicKeyToken=b77a5c561934e089". Type.GetType with this
> long string will succeed in .NET 2.0.
> In .NET, namespace and the associated assembly name are not necessarily
> related. Type "System.Data.SqlClient.SqlException" is not associated with
> "System.Data.SqlClient.dll" (which does not exist).
> -- Peter
> Site: http://www.eggheadcafe.com
> UnBlog: http://petesbloggerama.blogspot.com
> Short urls & more: http://ittyurl.net
>
>
> "Jeff" wrote:
>
thank you guys, you helped me solve this problem.
This is a bit embarrassing. I tryed to create an instance of this class:
min.test.DAL.SqlServer2005, but this class don't exist in my project.
min.test.DAL.SqlServer2005.SqlServer2005 is the class I needed... I had
forgot that I had a namespace with the same name as the class...
anyway I changed the .SqlServer2005 namespace to SqlClient so now I'm
accessing min.test.DAL.SqlClient.SqlServer2005
once again, thank you
cheers
Jeff
"Milosz Skalecki [MCAD]" <mily242@.DONTLIKESPAMwp.pl> wrote in message
news:FB62B8F3-8DAE-4E81-917C-935316F2CFE8@.microsoft.com...
> Jeff,
> In addition to Peter's reply, there's another way of obtaining the
> reference
> in ASP.NET 2.0 dynamic compilation enviroment. Please use
> System.Web.Compilation.BuildManager.GetType(min.test.Config.Settings.msgEl
ement.ProviderType,
> true);
> instead.
> Regards
> --
> Milosz
>
> "Peter Bromberg [C# MVP]" wrote:
>

Monday, March 26, 2012

This is very odd?? cant think of a descriptive title(files opened in different folder, ign

Hello all,
Sorry about the rubish title, this problem has really confused me. Here we go....
(not valid web addresses below, just an example)
I created a page called thepage.aspx in the web folder Myweb.co.uk/sites/thepage.apsx when i openwww.myweb.co.uk/sites/thepage.aspx, for some reason the page that is opened iswww.myweb.co.uk/different/folder/thepage.aspx (but the browser address bar displays the correct address)

thepage.aspx, could be default.aspx or contact.aspx, so for different sites desplays different info. Why would the browser goto the address and instead of reading the file thats right in front of it, go to a totaly differnt folder, and find a file with the same name and display that?
Please can someone help me on this odd event... i am extreamy puzzeled and cant think of any reason why?
Thank you for your time
Darren.breenen--
Regarding this...

breenen wrote:


...Sorry about the rubish title, this problem has really confused me. Here we go....
(not valid web addresses below, just an example)
I created a page called thepage.aspx in the web folder Myweb.co.uk/sites/thepage.apsx when i openwww.myweb.co.uk/sites/thepage.aspx, for some reason the page that is opened iswww.myweb.co.uk/different/folder/thepage.aspx (but the browser address bar displays the correct address)...Please can someone help me on this odd event... i am extreamy puzzeled and cant think of any reason why?...


...it looks like the site where you are building your page has subdomains and/or virtual directories setup...
...your hosting provider should be able to give you the actual map of apparent-names to actual-locations...
...in short, the general idea behind a virtual directory is that one can create a directory namedhttp://LocalHost/MySite and then make that "virtual directory" point to the actual-directory of c:\myMachineName\MyFolder\MySubFolder\ , or any other local physical directory. This allows one to create "friendly" site names and it makes it easier to create/delete/change the physical locations of a site without having to change the "virtual" address. The odd part is that depending upon how one accesses the files, one may see the virtual-path or the actual-path at a given time, which is what seems to be happening to you.
Sub-domains are similar to and leverage the concept of a virtual directory with the added affect that they can be "piggy-backed" off of an existing domain name. Suppose that one owns the domainhttp://www.WebLogicArts.com then that person can create any number of "sub-domain names" based on that domain, (provided the hosting company allows that), and those sub-domains would look generally like thishttp://MySubDomain1.WebLogicArts.com ,http://MySubDomain2.WebLogicArts.com ,http://MySubDomain3.WebLogicArts.com and so on.
HTH.
Thank you.

Saturday, March 24, 2012

This Message Board

Hi,

I'm just getting started with ASP.NET.

Is this message board created using on
of the starter kits of ASP.NET?Kind of. You can find the ASP.NET Forums for download on the forums main page in the left-hand menu (http://www.asp.net/forums). Click the Download the source link.

This Membership Provider has not been configured to support password retrieval.

Hi,
When an anonymous user has created an new account (with the CreateUserWizard
control), i want to let asp.net generate a password and to send it to the
address of the email provided by the new membershipuser in the
CreateUserWizard control.
i think i need to define a custom provider for membership and i tried this:
web.config:
--
<connectionStrings>
<add name="aspnetdb" connectionString="Data
Source=. \SQLEXPRESS;AttachDbFilename=|DataDirect
ory|\ASPNETDB.MDF;Integrated
Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<authentication mode="Forms" />
<membership>
<providers>
<add name="MyMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="aspnetdb"
enablePasswordRetrieval="true"
enablePasswordReset="true"
passwordFormat="Encrypted"
requiresQuestionAndAnswer="true"
applicationName="/"
/>
</providers>
</membership>
code-behind:
--
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If User.Identity.IsAuthenticated Then
Dim pw As String
pw = Membership.GetUser.GetPassword.ToString
End If
End Sub
But this generate the error:
"This Membership Provider has not been configured to support password
retrieval."
at line "pw = Membership.GetUser.GetPassword.ToString"
The problem is, i think, that it still the default provider which is used
and not my custom one. But i don't knwo how to fix it.Maybe i don't even
need to defiine a custom provider and maybe i can use the default?
Thanks for help
BenI changed this in web.config:
<membership defaultProvider="MyMembershipProvider">
but now, i get this error:
"You must specify a non-autogenerated machine key to store passwords in the
encrypted format. Either specify a different passwordFormat, or change the
machineKey configuration to use a non-autogenerated decryption key."
Do i have to change the line in web.config: passwordFormat="Encrypted" in
"Clear"? But then the security is not guaranteed?
"Ben" <b@.en.sd> schreef in bericht
news:OvshZOCgHHA.2396@.TK2MSFTNGP04.phx.gbl...
> Hi,
> When an anonymous user has created an new account (with the
> CreateUserWizard control), i want to let asp.net generate a password and
> to send it to the address of the email provided by the new membershipuser
> in the CreateUserWizard control.
> i think i need to define a custom provider for membership and i tried
> this:
> web.config:
> --
> <connectionStrings>
> <add name="aspnetdb" connectionString="Data
> Source=. \SQLEXPRESS;AttachDbFilename=|DataDirect
ory|\ASPNETDB.MDF;Integrat
ed
> Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
> </connectionStrings>
> <authentication mode="Forms" />
> <membership>
> <providers>
> <add name="MyMembershipProvider"
> type="System.Web.Security.SqlMembershipProvider, System.Web,
> Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
> connectionStringName="aspnetdb"
> enablePasswordRetrieval="true"
> enablePasswordReset="true"
> passwordFormat="Encrypted"
> requiresQuestionAndAnswer="true"
> applicationName="/"
> />
> </providers>
> </membership>
> code-behind:
> --
> Protected Sub Page_Load(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Me.Load
> If User.Identity.IsAuthenticated Then
> Dim pw As String
> pw = Membership.GetUser.GetPassword.ToString
> End If
> End Sub
>
> But this generate the error:
> "This Membership Provider has not been configured to support password
> retrieval."
> at line "pw = Membership.GetUser.GetPassword.ToString"
> The problem is, i think, that it still the default provider which is used
> and not my custom one. But i don't knwo how to fix it.Maybe i don't even
> need to defiine a custom provider and maybe i can use the default?
> Thanks for help
> Ben
>
>

This Membership Provider has not been configured to support password retrieval.

Hi,

When an anonymous user has created an new account (with the CreateUserWizard
control), i want to let asp.net generate a password and to send it to the
address of the email provided by the new membershipuser in the
CreateUserWizard control.

i think i need to define a custom provider for membership and i tried this:

web.config:
----
<connectionStrings>
<add name="aspnetdb" connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\ASPNETDB.MDF;Integrated
Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>

<authentication mode="Forms" />

<membership>
<providers>
<add name="MyMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="aspnetdb"
enablePasswordRetrieval="true"
enablePasswordReset="true"
passwordFormat="Encrypted"
requiresQuestionAndAnswer="true"
applicationName="/"
/>
</providers>
</membership>
code-behind:
----
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If User.Identity.IsAuthenticated Then
Dim pw As String
pw = Membership.GetUser.GetPassword.ToString
End If
End Sub

But this generate the error:
"This Membership Provider has not been configured to support password
retrieval."
at line "pw = Membership.GetUser.GetPassword.ToString"

The problem is, i think, that it still the default provider which is used
and not my custom one. But i don't knwo how to fix it.Maybe i don't even
need to defiine a custom provider and maybe i can use the default?

Thanks for help
BenI changed this in web.config:

<membership defaultProvider="MyMembershipProvider">

but now, i get this error:
"You must specify a non-autogenerated machine key to store passwords in the
encrypted format. Either specify a different passwordFormat, or change the
machineKey configuration to use a non-autogenerated decryption key."

Do i have to change the line in web.config: passwordFormat="Encrypted" in
"Clear"? But then the security is not guaranteed?

"Ben" <b@.en.sdschreef in bericht
news:OvshZOCgHHA.2396@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

Hi,
>
When an anonymous user has created an new account (with the
CreateUserWizard control), i want to let asp.net generate a password and
to send it to the address of the email provided by the new membershipuser
in the CreateUserWizard control.
>
i think i need to define a custom provider for membership and i tried
this:
>
web.config:
----
<connectionStrings>
<add name="aspnetdb" connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\ASPNETDB.MDF;Integrated
Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
>
<authentication mode="Forms" />
>
<membership>
<providers>
<add name="MyMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="aspnetdb"
enablePasswordRetrieval="true"
enablePasswordReset="true"
passwordFormat="Encrypted"
requiresQuestionAndAnswer="true"
applicationName="/"
/>
</providers>
</membership>
code-behind:
----
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If User.Identity.IsAuthenticated Then
Dim pw As String
pw = Membership.GetUser.GetPassword.ToString
End If
End Sub
>
>
But this generate the error:
"This Membership Provider has not been configured to support password
retrieval."
at line "pw = Membership.GetUser.GetPassword.ToString"
>
The problem is, i think, that it still the default provider which is used
and not my custom one. But i don't knwo how to fix it.Maybe i don't even
need to defiine a custom provider and maybe i can use the default?
>
Thanks for help
Ben
>
>
>
>

Thought about server controls

Hi all, I'm new to web app development and jumped right into ASP.NET - so of course I created an application full of asp:xxxxx controls with runat=server. Now I wonder if this is really not the recommended practice? Are there times that a plain old input box or drop down list would do better? Any advice would be appreciated! Thanks!Hello,

there are a few differences between these two kind of controls. In the following i just describe what i´m actually remember but maybe there are a bit it more...

First of all i give you a link where you can read the differences in detail:Introduction to ASP.NET Server Controls

Second is here a short summary:

1. Browser Compatibility
The HTML Server Controls have no mechanism of identifying the capabilities of the client browser accessing the current page.

ASP .NET Server Controls can however detect the target browser's capabilities and render themselves accordingly.

2. Object Model
The HTML Server Controls follow the HTML-centric object model.

ASP .NET Server Controls have an object model different from the traditional HTML and even provide a set of properties and methods that can change the outlook and behavior of the controls.

Sometimes i have heart that ASP.Net controls are a little bit more slowly than the appropriate html controls but i haven't experienced this by now...

Regards,
Ok, so you haven't experienced slower pages with server controls than a HTML control? I guess that is my main concern, I just want to make sure I am not wasting processor time with server controls when I may not really need them.
There is an overload. All the extra property and method of the asp.net version of the standard HTML need to be stored somewhere, as in the server memory.

While you may not experience slowdown, using them only when you need the extra fonctionality is the way to go IMHO.

What too much of them is will be up to you to decide though.
Thank you soo much!

Thursday, March 22, 2012

Thread just stops running

I have noticed how the thread I created just stops running. I have added
several exceptions to the thread
System.Threading.SynchronizationLockException
System.Threading.ThreadAbortException
System.Threading.ThreadInterruptedException
System.Threading.ThreadStateException
to see if I could get more information about why the thread stops running
but that code is never executed. Any ideas on how I can debug this?
Thanks in advance.You need to provide more context than this if you want the problem to be
solved
Regards,
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
----
"mareal" <m@.m.com> wrote in message
news:39C9F5D2-4988-4F95-A4C3-3EBF68E773FD@.microsoft.com...
>I have noticed how the thread I created just stops running. I have added
> several exceptions to the thread
> System.Threading.SynchronizationLockException
> System.Threading.ThreadAbortException
> System.Threading.ThreadInterruptedException
> System.Threading.ThreadStateException
> to see if I could get more information about why the thread stops running
> but that code is never executed. Any ideas on how I can debug this?
> Thanks in advance.
>
A thread stops running as soon as its parent thread stops running.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
What You S Is What You Get.
"mareal" <m@.m.com> wrote in message
news:39C9F5D2-4988-4F95-A4C3-3EBF68E773FD@.microsoft.com...
>I have noticed how the thread I created just stops running. I have added
> several exceptions to the thread
> System.Threading.SynchronizationLockException
> System.Threading.ThreadAbortException
> System.Threading.ThreadInterruptedException
> System.Threading.ThreadStateException
> to see if I could get more information about why the thread stops running
> but that code is never executed. Any ideas on how I can debug this?
> Thanks in advance.
>
Thanks Kevin. The parent thread (as I understand it) is the aspnet_wp proces
s
and as far I can tell, it is still running. The reason why I am saying this
is because I can access other ASP.NET applications on the same server. I hav
e
also checked the event log and I don't aspnet_wp being recycled. What am I
missing?
"Kevin Spencer" wrote:

> A thread stops running as soon as its parent thread stops running.
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> ..Net Developer
> What You S Is What You Get.
> "mareal" <m@.m.com> wrote in message
> news:39C9F5D2-4988-4F95-A4C3-3EBF68E773FD@.microsoft.com...
>
>
what is the looping structure in your thread? are you sure you are catching
all errors? what is its normal exit trigger?
if you code it correctly a thread will run the life of the appdomain its
created in.
-- bruce (sqlwork.com)
"mareal" <m@.m.com> wrote in message
news:E860CABF-18CE-4099-B44C-CB844EE57925@.microsoft.com...
| Thanks Kevin. The parent thread (as I understand it) is the aspnet_wp
process
| and as far I can tell, it is still running. The reason why I am saying
this
| is because I can access other ASP.NET applications on the same server. I
have
| also checked the event log and I don't aspnet_wp being recycled. What am I
| missing?
|
| "Kevin Spencer" wrote:
|
| > A thread stops running as soon as its parent thread stops running.
| >
| > --
| > HTH,
| >
| > Kevin Spencer
| > Microsoft MVP
| > ..Net Developer
| > What You S Is What You Get.
| >
| > "mareal" <m@.m.com> wrote in message
| > news:39C9F5D2-4988-4F95-A4C3-3EBF68E773FD@.microsoft.com...
| > >I have noticed how the thread I created just stops running. I have
added
| > > several exceptions to the thread
| > >
| > > System.Threading.SynchronizationLockException
| > > System.Threading.ThreadAbortException
| > > System.Threading.ThreadInterruptedException
| > > System.Threading.ThreadStateException
| > >
| > > to see if I could get more information about why the thread stops
running
| > > but that code is never executed. Any ideas on how I can debug this?
| > >
| > > Thanks in advance.
| > >
| >
| >
| >
Hello Bruce. I am sure I am catching all errors:
System.Threading.SynchronizationLockException
System.Threading.ThreadAbortException
System.Threading.ThreadInterruptedException
System.Threading.ThreadStateException
System.Exception
The looping structure is a
While True
... (local code)
... Call another method
... (+ local code)
End While
I have not added an exit trigger yet. I wanted to fix this problem first.
"bruce barker" wrote:

> what is the looping structure in your thread? are you sure you are catchin
g
> all errors? what is its normal exit trigger?
> if you code it correctly a thread will run the life of the appdomain its
> created in.
> -- bruce (sqlwork.com)
>
>
> "mareal" <m@.m.com> wrote in message
> news:E860CABF-18CE-4099-B44C-CB844EE57925@.microsoft.com...
> | Thanks Kevin. The parent thread (as I understand it) is the aspnet_wp
> process
> | and as far I can tell, it is still running. The reason why I am saying
> this
> | is because I can access other ASP.NET applications on the same server. I
> have
> | also checked the event log and I don't aspnet_wp being recycled. What am
I
> | missing?
> |
> | "Kevin Spencer" wrote:
> |
> | > A thread stops running as soon as its parent thread stops running.
> | >
> | > --
> | > HTH,
> | >
> | > Kevin Spencer
> | > Microsoft MVP
> | > ..Net Developer
> | > What You S Is What You Get.
> | >
> | > "mareal" <m@.m.com> wrote in message
> | > news:39C9F5D2-4988-4F95-A4C3-3EBF68E773FD@.microsoft.com...
> | > >I have noticed how the thread I created just stops running. I have
> added
> | > > several exceptions to the thread
> | > >
> | > > System.Threading.SynchronizationLockException
> | > > System.Threading.ThreadAbortException
> | > > System.Threading.ThreadInterruptedException
> | > > System.Threading.ThreadStateException
> | > >
> | > > to see if I could get more information about why the thread stops
> running
> | > > but that code is never executed. Any ideas on how I can debug this?
> | > >
> | > > Thanks in advance.
> | > >
> | >
> | >
> | >
>
>
then try
while true
try
.. your thread code
catch
try
log error
catch
. can't log
end try
end try
end while
note: your thread will be running with the asp.net worker process id, and
will have limited permissions.
-- bruce (sqlwork.com)
"mareal" <m@.m.com> wrote in message
news:6D2FC2CE-2FC8-40C9-A073-A02C859511F4@.microsoft.com...
| Hello Bruce. I am sure I am catching all errors:
|
| System.Threading.SynchronizationLockException
| System.Threading.ThreadAbortException
| System.Threading.ThreadInterruptedException
| System.Threading.ThreadStateException
| System.Exception
|
| The looping structure is a
|
| While True
| ... (local code)
| ... Call another method
| ... (+ local code)
| End While
|
| I have not added an exit trigger yet. I wanted to fix this problem first.
|
|
| "bruce barker" wrote:
|
| > what is the looping structure in your thread? are you sure you are
catching
| > all errors? what is its normal exit trigger?
| >
| > if you code it correctly a thread will run the life of the appdomain
its
| > created in.
| >
| > -- bruce (sqlwork.com)
| >
| >
| >
| >
| >
| > "mareal" <m@.m.com> wrote in message
| > news:E860CABF-18CE-4099-B44C-CB844EE57925@.microsoft.com...
| > | Thanks Kevin. The parent thread (as I understand it) is the aspnet_wp
| > process
| > | and as far I can tell, it is still running. The reason why I am saying
| > this
| > | is because I can access other ASP.NET applications on the same server.
I
| > have
| > | also checked the event log and I don't aspnet_wp being recycled. What
am I
| > | missing?
| > |
| > | "Kevin Spencer" wrote:
| > |
| > | > A thread stops running as soon as its parent thread stops running.
| > | >
| > | > --
| > | > HTH,
| > | >
| > | > Kevin Spencer
| > | > Microsoft MVP
| > | > ..Net Developer
| > | > What You S Is What You Get.
| > | >
| > | > "mareal" <m@.m.com> wrote in message
| > | > news:39C9F5D2-4988-4F95-A4C3-3EBF68E773FD@.microsoft.com...
| > | > >I have noticed how the thread I created just stops running. I have
| > added
| > | > > several exceptions to the thread
| > | > >
| > | > > System.Threading.SynchronizationLockException
| > | > > System.Threading.ThreadAbortException
| > | > > System.Threading.ThreadInterruptedException
| > | > > System.Threading.ThreadStateException
| > | > >
| > | > > to see if I could get more information about why the thread stops
| > running
| > | > > but that code is never executed. Any ideas on how I can debug
this?
| > | > >
| > | > > Thanks in advance.
| > | > >
| > | >
| > | >
| > | >
| >
| >
| >
Hello Bruce and thank you for your suggestion. I did what you told me and
unfortunately nothing changed. I can still see one thread (I only created
two) dying. Look at the log I am outputting:
The entry at the bottom represents me stopping the aspnet_wp.exe process.
Then you will thread 1 and 2. Around 8:37:04 is when thread 0 died...
DATE,TIME,EVENT CONTENT
3/9/2005,8:38:49 AM,Thread ID# 1;
3/9/2005,8:38:46 AM,Thread ID# 1;
3/9/2005,8:38:42 AM,Thread ID# 1;
3/9/2005,8:38:39 AM,Thread ID# 1;
3/9/2005,8:38:36 AM,Thread ID# 1;
3/9/2005,8:38:33 AM,Thread ID# 1;
3/9/2005,8:38:30 AM,Thread ID# 1;
3/9/2005,8:38:27 AM,Thread ID# 1;
3/9/2005,8:38:24 AM,Thread ID# 1;
3/9/2005,8:38:20 AM,Thread ID# 1;
3/9/2005,8:38:17 AM,Thread ID# 1;
3/9/2005,8:38:14 AM,Thread ID# 1;
3/9/2005,8:38:11 AM,Thread ID# 1;
3/9/2005,8:38:08 AM,Thread ID# 1;
3/9/2005,8:38:05 AM,Thread ID# 1;
3/9/2005,8:38:02 AM,Thread ID# 1;
3/9/2005,8:37:58 AM,Thread ID# 1;
3/9/2005,8:37:55 AM,Thread ID# 1;
3/9/2005,8:37:52 AM,Thread ID# 1;
3/9/2005,8:37:49 AM,Thread ID# 1;
3/9/2005,8:37:46 AM,Thread ID# 1;
3/9/2005,8:37:42 AM,Thread ID# 1;
3/9/2005,8:37:39 AM,Thread ID# 1;
3/9/2005,8:37:36 AM,Thread ID# 1;
3/9/2005,8:37:33 AM,Thread ID# 1;
3/9/2005,8:37:30 AM,Thread ID# 1;
3/9/2005,8:37:27 AM,Thread ID# 1;
3/9/2005,8:37:24 AM,Thread ID# 1;
3/9/2005,8:37:21 AM,Thread ID# 1;
3/9/2005,8:37:17 AM,Thread ID# 1;
3/9/2005,8:37:14 AM,Thread ID# 1;
3/9/2005,8:37:11 AM,Thread ID# 1;
3/9/2005,8:37:08 AM,Thread ID# 1;
3/9/2005,8:37:04 AM,Thread ID# 1;
3/9/2005,8:37:04 AM,Thread ID# 0;
3/9/2005,8:37:01 AM,Thread ID# 1;
3/9/2005,8:37:01 AM,Thread ID# 0;
3/9/2005,8:36:58 AM,Thread ID# 1;
3/9/2005,8:36:58 AM,Thread ID# 0;
3/9/2005,8:36:55 AM,Thread ID# 1;
3/9/2005,8:36:54 AM,Thread ID# 0;
3/9/2005,8:36:52 AM,Thread ID# 1;
3/9/2005,8:36:51 AM,Thread ID# 0;
3/9/2005,8:36:49 AM,Thread ID# 1;
3/9/2005,8:36:48 AM,Thread ID# 0;
3/9/2005,8:36:45 AM,Thread ID# 1;
3/9/2005,8:36:45 AM,Thread ID# 0;
3/9/2005,8:36:42 AM,Thread ID# 0;
3/9/2005,8:36:42 AM,Thread ID# 1;
3/9/2005,8:36:39 AM,Thread ID# 0;
3/9/2005,8:36:39 AM,Thread ID# 1;
3/9/2005,8:36:36 AM,Thread ID# 1;
3/9/2005,8:36:33 AM,Thread ID# 1;
3/9/2005,8:36:30 AM,Thread ID# 1;
3/9/2005,8:36:27 AM,Thread ID# 1;
3/9/2005,8:36:26 AM,Thread ID# 0;
3/9/2005,8:36:23 AM,Thread ID# 1;
3/9/2005,8:36:22 AM,Thread ID# 0;
3/9/2005,8:36:20 AM,Thread ID# 1;
3/9/2005,8:36:18 AM,Thread ID# 0;
3/9/2005,8:36:17 AM,Thread ID# 1;
3/9/2005,8:36:14 AM,Thread ID# 0;
3/9/2005,8:36:14 AM,Thread ID# 1;
3/9/2005,8:36:10 AM,Thread ID# 1;
3/9/2005,8:36:10 AM,Thread ID# 0;
3/9/2005,8:36:07 AM,Thread ID# 1;
3/9/2005,8:36:06 AM,Thread ID# 0;
3/9/2005,8:36:04 AM,Thread ID# 1;
3/9/2005,8:36:02 AM,Thread ID# 0;
3/9/2005,8:36:01 AM,Thread ID# 1;
3/9/2005,8:35:58 AM,Thread ID# 0;
3/9/2005,8:35:57 AM,Thread ID# 1;
3/9/2005,8:35:54 AM,Thread ID# 1;
3/9/2005,8:35:54 AM,Thread ID# 0;
3/9/2005,8:35:51 AM,Thread ID# 1;
3/9/2005,8:35:50 AM,Thread ID# 0;
3/9/2005,8:35:48 AM,Thread ID# 1;
3/9/2005,8:35:46 AM,Thread ID# 0;
3/9/2005,8:35:45 AM,Thread ID# 1;
3/9/2005,8:35:43 AM,Thread ID# 0;
3/9/2005,8:35:42 AM,Thread ID# 1;
3/9/2005,8:35:40 AM,Thread ID# 0;
3/9/2005,8:35:38 AM,Thread ID# 1;
3/9/2005,8:35:37 AM,Thread ID# 0;
3/9/2005,8:35:35 AM,Thread ID# 1;
3/9/2005,8:35:34 AM,Thread ID# 0;
3/9/2005,8:35:32 AM,Thread ID# 1;
3/9/2005,8:35:31 AM,Thread ID# 0;
3/9/2005,8:35:29 AM,Thread ID# 1;
3/9/2005,8:35:28 AM,Thread ID# 0;
3/9/2005,8:35:26 AM,Thread ID# 1;
3/9/2005,8:35:25 AM,Thread ID# 0;
3/9/2005,8:35:23 AM,Thread ID# 1;
3/9/2005,8:35:21 AM,Thread ID# 0;
3/9/2005,8:35:20 AM,Thread ID# 1;
3/9/2005,8:35:18 AM,Thread ID# 0;
3/9/2005,8:35:16 AM,Thread ID# 1;
3/9/2005,8:35:15 AM,Thread ID# 0;
3/9/2005,8:35:13 AM,Thread ID# 1;
3/9/2005,8:35:12 AM,Thread ID# 0;
3/9/2005,8:35:10 AM,Thread ID# 1;
3/9/2005,8:35:09 AM,Thread ID# 0;
3/9/2005,8:35:07 AM,Thread ID# 1;
3/9/2005,8:35:06 AM,Thread ID# 0;
3/9/2005,8:35:03 AM,Thread ID# 1;
3/9/2005,8:35:03 AM,Thread ID# 0;
3/9/2005,8:35:00 AM,Thread ID# 1;
3/9/2005,8:35:00 AM,Thread ID# 0;
3/9/2005,8:34:57 AM,Thread ID# 1;
3/9/2005,8:34:57 AM,Thread ID# 0;
3/9/2005,8:34:54 AM,Thread ID# 1;
3/9/2005,8:34:54 AM,Thread ID# 0;
3/9/2005,8:34:51 AM,Thread ID# 1;
3/9/2005,8:34:51 AM,Thread ID# 0;
3/9/2005,8:34:48 AM,Thread ID# 1;
3/9/2005,8:34:48 AM,Thread ID# 0;
3/9/2005,8:34:45 AM,Thread ID# 1;
3/9/2005,8:34:45 AM,Thread ID# 0;
3/9/2005,8:34:42 AM,Thread ID# 1;
3/9/2005,8:34:41 AM,Thread ID# 0;
3/9/2005,8:34:38 AM,Thread ID# 1;
3/9/2005,8:34:38 AM,Thread ID# 0;
3/9/2005,8:34:23 AM,ASP.NET 1.1.4322.0,Error,1000,N/A,aspnet_wp.exe (PID:
3796) stopped unexpectedly.
"bruce barker" wrote:

> then try
> while true
> try
> ... your thread code
> catch
> try
> log error
> catch
> .. can't log
> end try
> end try
> end while
> note: your thread will be running with the asp.net worker process id, and
> will have limited permissions.
> -- bruce (sqlwork.com)
> "mareal" <m@.m.com> wrote in message
> news:6D2FC2CE-2FC8-40C9-A073-A02C859511F4@.microsoft.com...
> | Hello Bruce. I am sure I am catching all errors:
> |
> | System.Threading.SynchronizationLockException
> | System.Threading.ThreadAbortException
> | System.Threading.ThreadInterruptedException
> | System.Threading.ThreadStateException
> | System.Exception
> |
> | The looping structure is a
> |
> | While True
> | ... (local code)
> | ... Call another method
> | ... (+ local code)
> | End While
> |
> | I have not added an exit trigger yet. I wanted to fix this problem first
.
> |
> |
> | "bruce barker" wrote:
> |
> | > what is the looping structure in your thread? are you sure you are
> catching
> | > all errors? what is its normal exit trigger?
> | >
> | > if you code it correctly a thread will run the life of the appdomain
> its
> | > created in.
> | >
> | > -- bruce (sqlwork.com)
> | >
> | >
> | >
> | >
> | >
> | > "mareal" <m@.m.com> wrote in message
> | > news:E860CABF-18CE-4099-B44C-CB844EE57925@.microsoft.com...
> | > | Thanks Kevin. The parent thread (as I understand it) is the aspnet_w
p
> | > process
> | > | and as far I can tell, it is still running. The reason why I am sayi
ng
> | > this
> | > | is because I can access other ASP.NET applications on the same serve
r.
> I
> | > have
> | > | also checked the event log and I don't aspnet_wp being recycled. Wha
t
> am I
> | > | missing?
> | > |
> | > | "Kevin Spencer" wrote:
> | > |
> | > | > A thread stops running as soon as its parent thread stops running.
> | > | >
> | > | > --
> | > | > HTH,
> | > | >
> | > | > Kevin Spencer
> | > | > Microsoft MVP
> | > | > ..Net Developer
> | > | > What You S Is What You Get.
> | > | >
> | > | > "mareal" <m@.m.com> wrote in message
> | > | > news:39C9F5D2-4988-4F95-A4C3-3EBF68E773FD@.microsoft.com...
> | > | > >I have noticed how the thread I created just stops running. I hav
e
> | > added
> | > | > > several exceptions to the thread
> | > | > >
> | > | > > System.Threading.SynchronizationLockException
> | > | > > System.Threading.ThreadAbortException
> | > | > > System.Threading.ThreadInterruptedException
> | > | > > System.Threading.ThreadStateException
> | > | > >
> | > | > > to see if I could get more information about why the thread stop
s
> | > running
> | > | > > but that code is never executed. Any ideas on how I can debug
> this?
> | > | > >
> | > | > > Thanks in advance.
> | > | > >
> | > | >
> | > | >
> | > | >
> | >
> | >
> | >
>
>
I found the problem. It was in the method being called by the thread. After
adding tons of logging and bunch of catches I found it. Here are the details
:
One of my test cases was to simulate a server crash. During the crashing, if
there was any communication that was already started by the client, it could
not be finished. So the “waiting for data” routine went into an infinite
loop.
I also learned that the following command:
sender.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket,
System.Net.Sockets.SocketOptionName.ReceiveTimeout, 10000)
does nothing if the server crashed right after the communication
(client/server) started. So I added a timer in the “waiting for data”
routine. When the time expires I exit the loop throwing an exception, which
gives control back to the thread.
Thank you Bruce, Kevin and Alvin.
"mareal" wrote:
> Hello Bruce and thank you for your suggestion. I did what you told me and
> unfortunately nothing changed. I can still see one thread (I only created
> two) dying. Look at the log I am outputting:
> The entry at the bottom represents me stopping the aspnet_wp.exe process.
> Then you will thread 1 and 2. Around 8:37:04 is when thread 0 died...
> DATE,TIME,EVENT CONTENT
> 3/9/2005,8:38:49 AM,Thread ID# 1;
> 3/9/2005,8:38:46 AM,Thread ID# 1;
> 3/9/2005,8:38:42 AM,Thread ID# 1;
> 3/9/2005,8:38:39 AM,Thread ID# 1;
> 3/9/2005,8:38:36 AM,Thread ID# 1;
> 3/9/2005,8:38:33 AM,Thread ID# 1;
> 3/9/2005,8:38:30 AM,Thread ID# 1;
> 3/9/2005,8:38:27 AM,Thread ID# 1;
> 3/9/2005,8:38:24 AM,Thread ID# 1;
> 3/9/2005,8:38:20 AM,Thread ID# 1;
> 3/9/2005,8:38:17 AM,Thread ID# 1;
> 3/9/2005,8:38:14 AM,Thread ID# 1;
> 3/9/2005,8:38:11 AM,Thread ID# 1;
> 3/9/2005,8:38:08 AM,Thread ID# 1;
> 3/9/2005,8:38:05 AM,Thread ID# 1;
> 3/9/2005,8:38:02 AM,Thread ID# 1;
> 3/9/2005,8:37:58 AM,Thread ID# 1;
> 3/9/2005,8:37:55 AM,Thread ID# 1;
> 3/9/2005,8:37:52 AM,Thread ID# 1;
> 3/9/2005,8:37:49 AM,Thread ID# 1;
> 3/9/2005,8:37:46 AM,Thread ID# 1;
> 3/9/2005,8:37:42 AM,Thread ID# 1;
> 3/9/2005,8:37:39 AM,Thread ID# 1;
> 3/9/2005,8:37:36 AM,Thread ID# 1;
> 3/9/2005,8:37:33 AM,Thread ID# 1;
> 3/9/2005,8:37:30 AM,Thread ID# 1;
> 3/9/2005,8:37:27 AM,Thread ID# 1;
> 3/9/2005,8:37:24 AM,Thread ID# 1;
> 3/9/2005,8:37:21 AM,Thread ID# 1;
> 3/9/2005,8:37:17 AM,Thread ID# 1;
> 3/9/2005,8:37:14 AM,Thread ID# 1;
> 3/9/2005,8:37:11 AM,Thread ID# 1;
> 3/9/2005,8:37:08 AM,Thread ID# 1;
> 3/9/2005,8:37:04 AM,Thread ID# 1;
> 3/9/2005,8:37:04 AM,Thread ID# 0;
> 3/9/2005,8:37:01 AM,Thread ID# 1;
> 3/9/2005,8:37:01 AM,Thread ID# 0;
> 3/9/2005,8:36:58 AM,Thread ID# 1;
> 3/9/2005,8:36:58 AM,Thread ID# 0;
> 3/9/2005,8:36:55 AM,Thread ID# 1;
> 3/9/2005,8:36:54 AM,Thread ID# 0;
> 3/9/2005,8:36:52 AM,Thread ID# 1;
> 3/9/2005,8:36:51 AM,Thread ID# 0;
> 3/9/2005,8:36:49 AM,Thread ID# 1;
> 3/9/2005,8:36:48 AM,Thread ID# 0;
> 3/9/2005,8:36:45 AM,Thread ID# 1;
> 3/9/2005,8:36:45 AM,Thread ID# 0;
> 3/9/2005,8:36:42 AM,Thread ID# 0;
> 3/9/2005,8:36:42 AM,Thread ID# 1;
> 3/9/2005,8:36:39 AM,Thread ID# 0;
> 3/9/2005,8:36:39 AM,Thread ID# 1;
> 3/9/2005,8:36:36 AM,Thread ID# 1;
> 3/9/2005,8:36:33 AM,Thread ID# 1;
> 3/9/2005,8:36:30 AM,Thread ID# 1;
> 3/9/2005,8:36:27 AM,Thread ID# 1;
> 3/9/2005,8:36:26 AM,Thread ID# 0;
> 3/9/2005,8:36:23 AM,Thread ID# 1;
> 3/9/2005,8:36:22 AM,Thread ID# 0;
> 3/9/2005,8:36:20 AM,Thread ID# 1;
> 3/9/2005,8:36:18 AM,Thread ID# 0;
> 3/9/2005,8:36:17 AM,Thread ID# 1;
> 3/9/2005,8:36:14 AM,Thread ID# 0;
> 3/9/2005,8:36:14 AM,Thread ID# 1;
> 3/9/2005,8:36:10 AM,Thread ID# 1;
> 3/9/2005,8:36:10 AM,Thread ID# 0;
> 3/9/2005,8:36:07 AM,Thread ID# 1;
> 3/9/2005,8:36:06 AM,Thread ID# 0;
> 3/9/2005,8:36:04 AM,Thread ID# 1;
> 3/9/2005,8:36:02 AM,Thread ID# 0;
> 3/9/2005,8:36:01 AM,Thread ID# 1;
> 3/9/2005,8:35:58 AM,Thread ID# 0;
> 3/9/2005,8:35:57 AM,Thread ID# 1;
> 3/9/2005,8:35:54 AM,Thread ID# 1;
> 3/9/2005,8:35:54 AM,Thread ID# 0;
> 3/9/2005,8:35:51 AM,Thread ID# 1;
> 3/9/2005,8:35:50 AM,Thread ID# 0;
> 3/9/2005,8:35:48 AM,Thread ID# 1;
> 3/9/2005,8:35:46 AM,Thread ID# 0;
> 3/9/2005,8:35:45 AM,Thread ID# 1;
> 3/9/2005,8:35:43 AM,Thread ID# 0;
> 3/9/2005,8:35:42 AM,Thread ID# 1;
> 3/9/2005,8:35:40 AM,Thread ID# 0;
> 3/9/2005,8:35:38 AM,Thread ID# 1;
> 3/9/2005,8:35:37 AM,Thread ID# 0;
> 3/9/2005,8:35:35 AM,Thread ID# 1;
> 3/9/2005,8:35:34 AM,Thread ID# 0;
> 3/9/2005,8:35:32 AM,Thread ID# 1;
> 3/9/2005,8:35:31 AM,Thread ID# 0;
> 3/9/2005,8:35:29 AM,Thread ID# 1;
> 3/9/2005,8:35:28 AM,Thread ID# 0;
> 3/9/2005,8:35:26 AM,Thread ID# 1;
> 3/9/2005,8:35:25 AM,Thread ID# 0;
> 3/9/2005,8:35:23 AM,Thread ID# 1;
> 3/9/2005,8:35:21 AM,Thread ID# 0;
> 3/9/2005,8:35:20 AM,Thread ID# 1;
> 3/9/2005,8:35:18 AM,Thread ID# 0;
> 3/9/2005,8:35:16 AM,Thread ID# 1;
> 3/9/2005,8:35:15 AM,Thread ID# 0;
> 3/9/2005,8:35:13 AM,Thread ID# 1;
> 3/9/2005,8:35:12 AM,Thread ID# 0;
> 3/9/2005,8:35:10 AM,Thread ID# 1;
> 3/9/2005,8:35:09 AM,Thread ID# 0;
> 3/9/2005,8:35:07 AM,Thread ID# 1;
> 3/9/2005,8:35:06 AM,Thread ID# 0;
> 3/9/2005,8:35:03 AM,Thread ID# 1;
> 3/9/2005,8:35:03 AM,Thread ID# 0;
> 3/9/2005,8:35:00 AM,Thread ID# 1;
> 3/9/2005,8:35:00 AM,Thread ID# 0;
> 3/9/2005,8:34:57 AM,Thread ID# 1;
> 3/9/2005,8:34:57 AM,Thread ID# 0;
> 3/9/2005,8:34:54 AM,Thread ID# 1;
> 3/9/2005,8:34:54 AM,Thread ID# 0;
> 3/9/2005,8:34:51 AM,Thread ID# 1;
> 3/9/2005,8:34:51 AM,Thread ID# 0;
> 3/9/2005,8:34:48 AM,Thread ID# 1;
> 3/9/2005,8:34:48 AM,Thread ID# 0;
> 3/9/2005,8:34:45 AM,Thread ID# 1;
> 3/9/2005,8:34:45 AM,Thread ID# 0;
> 3/9/2005,8:34:42 AM,Thread ID# 1;
> 3/9/2005,8:34:41 AM,Thread ID# 0;
> 3/9/2005,8:34:38 AM,Thread ID# 1;
> 3/9/2005,8:34:38 AM,Thread ID# 0;
> 3/9/2005,8:34:23 AM,ASP.NET 1.1.4322.0,Error,1000,N/A,aspnet_wp.exe (PID:
> 3796) stopped unexpectedly.
>
> "bruce barker" wrote:
>
Nice debugging work!
Kevin Spencer
Microsoft MVP
.Net Developer
What You S Is What You Get.
"mareal" <m@.m.com> wrote in message
news:078C5B1D-6B25-4E0E-B0B5-3B9326193A32@.microsoft.com...
>I found the problem. It was in the method being called by the thread. After
> adding tons of logging and bunch of catches I found it. Here are the
> details:
> One of my test cases was to simulate a server crash. During the crashing,
> if
> there was any communication that was already started by the client, it
> could
> not be finished. So the "waiting for data" routine went into an infinite
> loop.
> I also learned that the following command:
> sender.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket,
> System.Net.Sockets.SocketOptionName.ReceiveTimeout, 10000)
> does nothing if the server crashed right after the communication
> (client/server) started. So I added a timer in the "waiting for data"
> routine. When the time expires I exit the loop throwing an exception,
> which
> gives control back to the thread.
> Thank you Bruce, Kevin and Alvin.
> "mareal" wrote:
>