|
this is something that is not handled by .net for you - its a general oo problem.
the only way to reduce this is to use a utility object to set values, and that object raises the event.
ps you should not:
NotifySubscribers{this);<br />
propA = value;
it should be:
<br />
propA = value;<br />
NotifySubscribers{this);<br />
otherwise the clients can't see the new value....
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
The mistaken logic in the code was an oversight. Thanks.
The reason I this could be a possibility, is that I read somewhere that things like logging can be added to applications by the use of MessageSinks and Custom attributes. In this model, calls are intercepted at runtime by a series of object which implement IMessageSink.
Although I didn't mention it, the above calls to NotifySubscribers{this) would really be calls to a UnitOfWork object which would then update or validate the objects in its charge.
Robert Zurer
|
|
|
|
|
In my Window Form Application, I create many modaless forms(by different class).
How can I get the current focused form object in any forms?
Thanks a lot.
Evan Chen
|
|
|
|
|
when i type in System.Environment.GetFolderPath it's asking for a value of type System.Environment.SpecialFolder but when i try to type that in it doesn't show up in the list that comes up. what am i doing wrong?
thanks,
Rob
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
show up in the list that comes up
I guess you are referring to intellisense.
This works fine for me:
<br />
this.textBox1.Text =<br />
System.Environment.GetFolderPath(System.Environment.SpecialFolder.Recent);<br />
R.Bischoff
.NET, Kommst du mit?
|
|
|
|
|
why is the System namespace in both System.dll and mscorlib.dll? and when i use object browser to look in the mscorlib.dll it has System.Environment but no SpecialFolder enum listed. so why does the code that you gave me work if it won't show up in object browser or intellisense? are there other classes, namespaces, etc. that are not listed?
thanks,
Rob
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
This will enumerate all special folders with their respective path.
requiremnts, create a ListView named listView1 in your win form, then paste code into button event handler or Initialize()
<br />
private void button2_Click(object sender, System.EventArgs e)<br />
{<br />
ListViewItem lvi = null;<br />
foreach(Environment.SpecialFolder sf in Enum.GetValues(typeof(Environment.SpecialFolder)))<br />
{<br />
lvi = new ListViewItem(Enum.Parse(typeof(Environment.SpecialFolder), sf.ToString(), true).ToString());<br />
lvi.SubItems.Add(Environment.GetFolderPath(sf));<br />
listView1.Items.Add(lvi); <br />
}<br />
}<br />
R.Bischoff
.NET, Kommst du mit?
|
|
|
|
|
I guess the subject says it all. I have a C# project that calls native methods. I have set the "Allow unsafe code blocks" option to TRUE in the project build configuration dialog. However every time I restart studio, builds of this project will turn up the message that this option is set to false. In order to fix the problem, I must set the option to false and apply changes, then set it back to true and apply changes again.
Is there a fix for this bug? I hate having to repeat myself again and again every time I open the project.
|
|
|
|
|
Did Vs.NET make a clean exit, after you applied the changes? IOW, change setting, do a complete rebuild, and exit VS.NET, restart. Should work...
Did you have two copies of VS.NET open?
leppie::AllocCPArticle("Zee blog");
|
|
|
|
|
Yes. Changes were applied, solution was saved, rebuild was done. VS did a graceful exit and when I return I get the same message. In fact, examination of the configuration properties page reveals that the setting is correct - but for some reason the compiler is not acting in accordance with the setting until you follow the "set it false/apply/set it true/apply" methodology described above.
|
|
|
|
|
hi,
Want to dynamically generate a xml format from sql server . The data base has about 15 parent child relationship tables.
What is the best approach in .net environment
thanks.
jag
|
|
|
|
|
Maybe use DataSets.
<br />
System.Data.DataSet ds;<br />
ds.WriteXml("xmlFileName", System.Data.XmlWriteMode.WriteSchema);<br />
ds.WriteXmlSchema("xmlSchemaFileName");<br />
also look into SQLXML , you can actually write T-SQL to return back pure XML from sql server.
R.Bischoff
.NET, Kommst du mit?
|
|
|
|
|
Hy,
Help in progress bar.
I like alter scrolling in progress bar, but Windows Form
|
|
|
|
|
|
Done with writing the post or the program?
I passionately hate the idea of being with it, I think an artist has always to be out of step with his time.
-Orson Welles
|
|
|
|
|
Quick question:
Is an instance of a struct an object? If not, what is it? What about an instance of an enum ?
Thanks,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
Nope.
The C# struct keyword maps to the System.ValueType class.
An enum is an instance of System.Enum, which derives from ValueType.
Of course, both of these ultimately derive from System.Object. It's just that the CLR loads System.ValueType and its derived classes into the stack, whereas System.Object gets loaded onto the heap.
Conclusion of the day, don't believe a developer, his mind is always changing.
-Stephane Rodriguez.
|
|
|
|
|
Here's my dilemma:
I'm writing some documentation where I refer to an instance of the DateTime struct. When I originally wrote it, I referred to it as the "DateTime object". But then I said, well it's not really an instance of a class, so is it really an "object"?
After I had posted my question (above), I started thinking about what makes an instance of something an "object". And it would seem to me that how it's allocated (stack or heap) should not matter.
Isn't an object an instance of a type that has properties and/or methods?
If that's the criteria then an instance of DateTime should be considered an object, even if it's not an instance of class. It has properties and methods which means that it behaves like an object. Am I right?
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
If you look at the MSDN docs, it says:
The DateTime value type represents dates and times with values ranging from 12:00:00 midnight, January 1, 0001 Anno Domini (Common Era) to 11:59:59 P.M., December 31, 9999 A.D. (C.E.)
I would either call it a type or a value type...but not an object. Because any programmer who absolutely adores CLR internals and is very picky about semantics is going to say, "Oh, it's an object, allocated on the heap."
I have also lived some years in Spain, and there people don't accept that you speak bad spanish. I usually compensate by speaking loud and accusing people of being stupid because they don't understand me. It usually works quite well.
-jhaga on non-native languages
|
|
|
|
|
hi !
i need to know all (my) network-interfaces-addresses.
(so all addresses
iep = new IPEndPoint(IPAddress.Any,port);
sock.Bind(iep);
would affect
is this:
127.0.0.1
+
all addresses i get with
{
IPHostEntry hostInfo = Dns.Resolve(Dns.GetHostName());
IPAddress[] address = hostInfo.AddressList;
}
????
thanks
andi
|
|
|
|
|
I have this call
Invoke(new TreeViewThreadCallback(this.InsertNode), new object[] {node});
I want to stop this thread so I can initiate another on it.
please help
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
I've trouble getting this work, not sure why. Trying to write encrypted to a memory stream. Exception was thrown with everycall to MemoryStream.Close(): "System.NotSupportedException. Memory Stream is not expandable"
code looks like this:
ASCIIEncoding AE = new ASCIIEncoding ();
byte[] buffer = new byte [10];
buffer = ASCIIEncoding.GetBytes("ABCDE");
byte[] Key = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16};
byte[] IV = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16};
TcpClient TCP = new TcpClient("localhost",11000);
NetworkStream NetStream = TCP.GetStream();
RijndaelManaged RMCrypto = new RijndaelManaged();
MemoryStream mstream2 = new MemoryStream(buffer, 5, 5, true, true);
CryptoStream cstream2 = new CryptoStream(
mstream2,
RMCrypto.CreateEncryptor(Key, IV),
CryptoStreamMode.Write);
StreamWriter cswriter = new StreamWriter(cstream2);
cswriter.Write(AE.GetBytes("AA"));
cswriter.Flush();
cswriter.Close(); <---- EXCEPTION HERE! "memory stream is not expandable"???
Help! What happenned here?
norm
|
|
|
|
|
Your code is a bit confuse:
norm wrote:
byte[] buffer = new byte [10];
buffer = ASCIIEncoding.GetBytes("ABCDE");
Why are you initializing if you are going to set it on the next line?
norm wrote:
MemoryStream mstream2 = new MemoryStream(buffer, 5, 5, true, true);
CryptoStream cstream2 = new CryptoStream(
mstream2,
RMCrypto.CreateEncryptor(Key, IV),
CryptoStreamMode.Write);
Doing this will write on the MemoryStream. This would be ok, but why don't you use the default constructor (which creates an expandable memorystream)? See what's on MSDN about the constructor you used:
Initializes a new non-resizable instance of the MemoryStream class based on the specified region of a byte array, with the CanWrite property set as specified.
This means you'll never be able to write more than the size of "ABCDE" in ASCII encoding, i.e., 5 bytes. This is very low, and some compression schemes add salt. If you eliminate the "buffer" variable, you probably will get the code working right.
You can do it on anything you choose - from .bat to .net - A customer
|
|
|
|
|
Thanks, first of all.
Quote: "byte[] buffer = new byte [10];
buffer = ASCIIEncoding.GetBytes("ABCDE");"
>> This is merely cut-&-paste mistakes. Forget it.
The following constructors allows me to specify that the stream is expandable.
MemoryStream mstream2 = new MemoryStream(buffer, 5, 5, true, true);
Using another overload, "Capacity" is NOT expandable and is set to length of input/specified "buffer".
MemoryStream mstream2 = new MemoryStream(buffer);
QUESTION: I tried both ways. Now, how do I work with default constructor that takes no argument? How can I associate a buffer to the stream after construction?
memoryStream.GetBuffer() retrives buffer. But there's no SetBuffer member for me to associate MemoryStream with a buffer.
Thanks.
norm
|
|
|
|
|
norm wrote:
memoryStream.GetBuffer() retrives buffer. But there's no SetBuffer member for me to associate MemoryStream with a buffer.
Byte[]'s are not expandable, so any MemoryStream you create with them will make your stream fixed-size. Either pass a buffer bigger or use a memorystream-managed buffer.
This is what I don't get. Why do you need to set the memorystream buffer? After all, if I understood you correctly, what you need is a byte[] with the encrypted data, right?
Why can't you simply call memoryStream.GetBuffer() and create it with new MemoryStream() ?
You can do it on anything you choose - from .bat to .net - A customer
|
|
|
|
|