|
OK, in that case your converter sucks. Just add the reference ( there's a references section on the top of the project, just right click and choose add reference, and look for System.Web, or whatever it is you need ) and you should be fine.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Thanks a lot.
I have added the statment:
using System.Web.UI.WebControls;
I no longet get the error. But when I write using System. I don't see "Web" in the intellisense. Why?? ANy idea.
|
|
|
|
|
Intellisense is unreliable at the best of times - don't worry about it.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Cool!
I have another Q, how do I create an ascx file for a user control.
When I click on "Add user control", I get a xyz.cs file and not ascx file.
This is the last Q...
|
|
|
|
|
There are two types of controls, one that has an ascx, and one that is code only. Make sure you're creating a 'web user control'.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
How do I add the ascx file? If I add the Usercontrol file, I get .cs extension file. I then change the extension to .ascx but I can't view the code. What am i doing wrong.
This is really bugging.
|
|
|
|
|
Changing the extension would be a dumb thing to do. For starters, you need a .cs file in a user control as well.
Like I said, if I right click on the project and choose 'Add Web User Control', I get an ascx. It's a custom control that doesn't have an ascx file. There is something very screwy about your setup, or how you're going about this.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
You probably have a Windows Forms project when you want an ASP.NET project. Can you verify that?
How to know: select the project name in the Solution Explorer. The property window should have only two items, project file and project folder. Project folder should be disabled. If project folder is a normal path, it's a Windows Forms project. If it is a URL (http://localhost....) it's an ASP.NET project.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Where would I place a .config file for a windows serice? Would it only be used when I install the service or would it be used everytime the service was started?
Cheers,
Jim
|
|
|
|
|
The .config is always opened when the corresponding executable tries to access it and will have to be positioned at the same location as the executable.
(I assume you mean the "myProgramName.exe.config" file)
|
|
|
|
|
Yes, that's exactly what I meant. I just don't know where exactly the executable sits when its a service. I suppose it doesn't actually go anywhere and calls the same one anyways? Should I just install the service as per usual?
Cheers,
Jim
|
|
|
|
|
When you install your app as a service the current executable path is used, and the same executable path is used every time the service is started.
mav
|
|
|
|
|
Oh Really? That would mean that i only have to recompile a file after I have installed it, as opposed to uninstalling and reinstalling the file every time.
Thanks,
Jim
|
|
|
|
|
I have a question that I'm sure some of the experts here will be able to answer.
I have a custom business object that, by itself, contains a small amount of data. However, during runtime, that object may create and hold more data depending on how it is used. Basically, I want the object to grow-on-the-fly rather than allocate everything all at once.
The way I've set this up is through a property in the object:
public BigStuff[] HugeData
{
get
{
if (this.hugeData == null)
{
this.hugeData = new HugeData();
}
return this.hugeData;
}
}
This way, hugeData is only allocated when it is needed.
Now to the problem: multithreading. This property has the potential to allocate hugeData multiple times if the get_HugeData method is called asynchronously from multiple threads. What is the best way to get around this? Currently, I've placed a [MethodImpl(MethodImplOptions.Synchronized)] tag on the getter of the property, but I don't know how efficient that is, or whether there's a better way to do this. Any thoughts?
Tech, life, family, faith: Give me a visit.
Judah Himango
|
|
|
|
|
Internally this attribute uses the lock(this) construct which is in my opinion rather bad practice. I always prefer locking against a private member variable. If you do so you also have more control over what is locked against what (sound strage heh? )
Efficiency is the same with both solutions and I dont think this should be a problem (unless you are going to call this hundreds of times per second).
|
|
|
|
|
Whoa - so it actually locks the entire object? Are you sure? How, then, would that attribute work on static classes? Sheesh that's scary, I didn't know it locked the entire object. Yeah, maybe I'll lock my private hugeData then, unless locking isn't allowed on a null variable.
Tech, life, family, faith: Give me a visit.
Judah Himango
|
|
|
|
|
Dont get me wrong. Its locked against everything which also uses this attribute or lock(this) (at least in this class).
And locking doesnt lock against variables, it locks against objects. So nulls are not allowed. Dont be shy - just create a private member variable just to lock this function .
private object _myHugeDataLock = new object();
lock (myHugeDataLock) {
if (this.hugeData == null)
{
this.hugeData = new HugeData();
}
}
return this.hugeData;
|
|
|
|
|
Robert Rohde wrote:
Dont get me wrong. Its locked against everything which also uses this attribute or lock(this) (at least in this class).
Ok, I'm not following you now. Are you saying that
[MethodImpl(MethodImplOptions.Synchronized)]
void Test
{
DoSomething();
}
Is equivalent to:
void Test
{
lock(this)
{
DoSomething();
}
}
? The disassembled IL is very much different, but I haven't tested whether they are functionally identical.
Robert Rohde wrote:
And locking doesnt lock against variables, it locks against objects. So nulls are not allowed.
Ah of course, I knew that, but my mind told me otherwise.
Robert Rohde wrote:
Dont be shy - just create a private member variable just to lock this function .
Allocating an object for every function I want synchronized seems like such a waste! :-p I suppose this is another one of those tradeoffs where memory or performace is sacrificed for the sake of synchronized code.
Tech, life, family, faith: Give me a visit.
Judah Himango
|
|
|
|
|
Ah, after doing some testing, I've found what the Synchronized attribute does (and I think I now understand what you were saying).
[sycn attribute here]
void Test()
{
DoLengthy();
}
[sycn attribute here]
void Test2()
{
}
ThreadStart ts1 = Test;
ThreadStart ts2 = Test2;
ts.BeginInvoke(null, null);
ts.BeginInvoke(null, null);
Test2, despite doing absolutely nothing, will not finish until Test finishes! In other words, all methods with the synchronized attribute will be locked, not just the method being called. <Grrr> that stinks, I wonder what thinking went into that design. Well, I learned something new today.
Thanks for your insight.
Tech, life, family, faith: Give me a visit.
Judah Himango
|
|
|
|
|
Hi,
I should first make it clear I know virtually nothing about c# & .NET (so please speak slowly and use short words )
I'm modifying a c# program someone else wrote which, as part of its process sends a mail using MailMessage.
This works... However when the message arrives some (not all) of the new lines (CR,LF) are messed up.
I noticed that if I open the mail in outlook and go View->Encoding this is set to "Western European (ISO)" if I switch this to "Western European (Windows)" the lines look right again.
So I looked into this and noticed the BodyEncoding member, but still can't get this working.
My code is
<br />
MailMessage mail = new MailMessage();<br />
<br />
mail.To = "me@somewhere.com";<br />
mail.Cc = "";<br />
mail.Bcc = "";<br />
mail.From = "Someone@SomewhereElse.com";<br />
mail.Body = <String read from a file somewhere>;<br />
SmtpMail.SmtpServer = "smtp.MyServer.com";<br />
SmtpMail.Send( mail );<br />
<br />
I have tried adding...
<br />
mail.BodyEncoding = System.Text.Encoding.GetEncoding(1252);<br />
and
<br />
mail.BodyEncoding = System.Text.Encoding.Default;<br />
but still the message is always displayed as "Western European (ISO)", does anyone have any idea how I can fix this?
Cheers
DAve
|
|
|
|
|
I have this really wierd error messgae popping up when I run my application (ASP.NET with C# code behind).
I am having the app create a log file and directing the stream to a share on the server.The wierd thing about this is...the application works fine from my machine but when I try the same on one of my fellow developers...it breaks out with this error message. I am not sure if this is a security issue because all of us have the same security settings.
I also turned impersonate=true and given my username and passsword for users in the web.config. and changed the setting in the local security settings per http://www.dotnet247.com/247reference/msgs/25/127951.aspx.
I cannot figure out what and where the trouble is...beacuse the stack trace is no help!!!
I appreciate anyone what can shed a light on this issue
Menita
|
|
|
|
|
This should be a simple answer, but I'm a bit stumped.
I have a Form with a GroupBox of minimum height acting as a visual seperator
in the form. When the Form loads I want only the upper portion of the window
to be viewable. To accomplish this I'm attempting to set the Height property of the form. My problem is how to I equate the location of my GroupBox seperator to the window height ?
-------------------
| |
| |
| |
| |
----------------- <- This is the Group Box I'm using as a seperator
| |
| |
| |
| |
| |
| |
| |
-------------------
|
|
|
|
|
To reduce the size of the form so that the GroupBox is not visible:
<br />
form1.Height = groupBox1.Top + (form1.Height - form1.ClientSize.Height)<br />
If the group box should be visible just add the height of it:
<br />
form1.Height = groupBox1.Top + (form1.Height - form1.ClientSize.Height) + groupBox1.Height<br />
|
|
|
|
|
Thanks Robert, I tried Height=GB.Top, but I didn't add the client size difference...thanks.
|
|
|
|
|
I am new to C# and I know this may be easy for most but I have a question and it may have to do more with variables between form.cs files and other cs files, but here goes. I know the easiest way to add custom buttons to a messagebox is to use a form and make my own. I am looking for a way to have "yes, yes to all, no, no to all" buttons on a messagebox. My question is, if I have a class not in a form cs file and I need to display this messagebox, how do I do this and make it modal, and how do I catch the values (in the none form cs class) of the button that is clicked by the user.
|
|
|
|