|
OK, you are right again. I finally found the solution. Always wondering where or what was releasing my waitone(), I realised that it must come from other instances of my class. So i thought why the heck can they? I always create a new ManualResetEvent, don't I?! The answer is yes, but it was static!
Shame on me and thanks for your answers,
vb
modified on Tuesday, December 30, 2008 5:50 PM
|
|
|
|
|
Hi!
I have a project say 'project1'. I have added some configuration sections to app.config file. The configuration sections contain initialization data for various objects. The objects read those configration information to initialize themselves. It works correctly.
But when i create a class library of this project and add it to a web application the objects become unable to read thier configuration data from app.config file.
So when i add that data to the web.config file it works fine.
But i want my objects be able to read configuration data from the app.config file. How can i do that?
Thanks.
|
|
|
|
|
Hi peshawarcoder,
To me, this sounds like a permission problem / path problem. Could you post the error that it gives ?
Cheers,
|
|
|
|
|
Class libraries cannot have config files. They are libraries of code that become part of the application project itself. Using the normal built-in methods, they must get their settting from the host applications config files, be it app.config for WinForms or web.config for ASP.NET. Outside of that, you'll have to implement your own configuration settings retrieval scheme.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks.
Your suggestion to implement my own configuration setting retrieval scheme will help me to a great extent. Did you mean to add configuration sections to the web.config file and provide code that my objects use to get information from their respective configuration sections in the web.config file. (I have already done this.)
But i want that there should be a separate configuration file from which objects instantiated from the classes in the class library get thier data.
|
|
|
|
|
peshawarcoder wrote: Did you mean to add configuration sections to the web.config file and provide code that my objects use to get information from their respective configuration sections in the web.config file
No. You implement your own configuration manager so that your code can specify which file to open to get configation settings. You can probably start with this[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I try to create a SoapExtensionAttribute, but when I try to add a web reference the SoapExtensionAttribute don't be insertede in a client proxy side, what I have to do to add the SoapExtensionAttribute in the client proxy side when I add the web refenrece.
ps.: I can't put the soapExtensionTypes in the app.config because in the current project has another web services from third-parties, and I implement a SFDE but don't work.
Any ideia?
Att.
Walter
Sorry by english
|
|
|
|
|
hi all
maybe you see software like "folder guard" or "lock file"
i want to wtite a software that hide a file and no one can see it while i unhide it.
how can do that in win XP
please help me
|
|
|
|
|
I have not seen those mentioned by you, but you can achive what you are expacting by encrypting, encoding or moving files to Isolated Storage.... There are many ways to do it...
|
|
|
|
|
Gents / Ladies,
I have a monetary value in a database that I extract. Due to this, I use decimal rather then double if I want to do any calculations later on. I run the following method :
decimal? abaCnt;
abaCnt = ((abCnt / 100) * 19);
txtBTW.Text = abaCnt.ToString();
This works fine, however the outcome is 967.9304 ... and I want it rounded off at 2 decimals : 967.93
if I use double, I can easily round it if by using :
double AA = Convert.ToDouble(this.txtBTW.Text);
double subrounded = Math.Round(AA, 2);
Is there a simple way doing this with the parameter decimal as well.
I couldn't find anything on the net that could explain to me how it's done.
Cheers,
|
|
|
|
|
The Math class has an overload of the Round method that takes a decimal and the wanted precision.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
txtBTW.Text = abaCnt.ToString( "0.00" );
|
|
|
|
|
Gents/ladies
Thank you for you prompt and swift reply. I highly appreciate it.
I don't think the Math class is actually taking decimal as a valid input but only double .
There is no conversion possible between double and decimal due to the well-known round-off problem that comes with this.
I managed to fix it another way :
decimal round = Convert.ToDecimal(abaCnt);
decimal? result = Decimal.Round(round, 2);
txtOffBTWTotaal.Text = result.ToString();
This did the trick.
Kind regards,
|
|
|
|
|
Rick van Woudenberg wrote: I don't think the Math class is actually taking decimal as a valid input but only double.
Don't think. Read.
MSDN Library: Math.Round method[^]
---
Year happy = new Year(2007);
|
|
|
|
|
Rick van Woudenberg wrote: I don't think the Math class is actually taking decimal as a valid input but only double.
"Thinking" is not allowed when you troubleshoot a problem. You either "know it" or you need to find out for sure.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
fine ...
I KNOW that the math class does not accept decimal as a parameter , only double .
Decimal.Round does ...
how's that ?
|
|
|
|
|
Rick van Woudenberg wrote: I KNOW that the math class does not accept decimal as a parameter , only double.
Upon which facts does your "knowledge" base? How come MSDN claims the opposite (Math.Round Method (Decimal, Int32)[^]) and the following code snippet compiles without any complaints?
decimal x = new decimal(5.555);
x = Math.Round(x, 2));
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Rick van Woudenberg wrote: I KNOW that the math class does not accept decimal as a parameter , only double.
Really? The .NET Framework documentation disagrees: Math.Round overloads[^].
What I said was a pirce of advice in ALL troubleshooting situations. I've been doing computer and programming work for over 21 years. What I've learned in those years is that in every single troubleshooting problem, no matter if your debugging code or trying to find the problem with a dishwasher, you MUST verify every fact you think you know to be successful at finding the problem or solution. That's why I said there is no "thinking" in troubleshooting. You either know "it" for a fact because you have the proof to back it up, or you don't know "it" and your guessing or making assumptions that are, far more often than not, incorrect.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
hi,
I'm trying to serialize CAO object and save it in file on client computer. I tried some possible solutions but they haven't worked. (there was exception on server side)
My class looks similar to this example:
<br />
[Serializable]<br />
public class Test : MarshalByRefObject<br />
{<br />
<br />
[Serializable]<br />
public class InnerClass : MarshalByRefObject {...}<br />
<br />
public byte[] GetStream()<br />
{<br />
MemoryStream stream = new MemoryStream();<br />
BinaryFormatter serializer = new BinaryFormatter(); <br />
serializer.Serialize(stream, this);<br />
return stream.GetBuffer();<br />
}<br />
}<br />
Everything works fine until I call GetStream() method.
Even returning simple byte array doesn't work
What is wrong?
|
|
|
|
|
mdzieg wrote: was exception on server side)
What was the exception? If the server threw an exception, it seems you might be using remote objects. Is that true?
Also, recurse through the InnerException, as this often has useful information.
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
Yes, client invoke method from CAO object to serialize it.
I just need to save CAO object on client computer.
The exception is thrown on server side.
Type 'System.Runtime.Remoting.ServerIdentity' in Assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.
|
|
|
|
|
heh, even serializing in separate thread on server...
<br />
public byte[] GetStream()<br />
{<br />
TestSerializer td = new TestSerializer(Test.EnquireStream);<br />
IAsyncResult ia = td.BeginInvoke(this, null, null);<br />
return td.EndInvoke(ia);<br />
}<br />
<br />
public static byte[] EnquireStream(Test test)<br />
{<br />
MemoryStream stream = new MemoryStream();<br />
BinaryFormatter serializer = new BinaryFormatter();<br />
serializer.Serialize(stream, test);<br />
return stream.GetBuffer();<br />
}<br />
}<br />
delegate byte[] TestSerializer(Test test);<br />
results the same exception, I thought it may be the same problem as with windows forms controls...
|
|
|
|
|
Problem solved:
BinaryFormatter formatter = new BinaryFormatter(new System.Runtime.Remoting.Messaging.RemotingSurrogateSelector(), new StreamingContext(StreamingContextStates.All));
read this: http://msdn2.microsoft.com/en-us/library/system.runtime.remoting.messaging.remotingsurrogateselector.aspx
-- modified at 15:28 Tuesday 23rd January, 2007
|
|
|
|
|
I'm looking for code to enable sharing (read/writable) on a drive, programmatically. Note that this is different from mapping a network drive, of which I've found several examples.
Is it possible to do this programmatically (assuming of course that the app doing this has the right permissions)?
Thanks!
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
Hey Marc,
I haven't figured out yet how to share a complete drive, but I did manage to share individual folders. I understand why you want to share an entire drive, especially when it's a local drive. There is no need in sharing each individual folder. If your drives look like mine then there's probably ten million of 'em. I though I just post the file sharing solution anyway, is case you're interested.
This is done through the FileShare enumerator.
The .NET Framework provides the File class equipped with methods to create, save, open, copy, move, delete, or provide detailed information about, files. Based on its functionality, the File class is typically used to assist the other classes with their processing operations. To effectively provide this support, all File's methods are static; which means that you will usually not need to declare a File variable to access them. One of the valuable operations that the File class can perform is to check the existence of the file you want to use. For example, if you are creating a new file, you may want to make sure it doesn't exist already because if you try to create a file that exists already, the compiler may first delete the old file before creating the new one. This could lead to unpredictable result, especially because such a file is not sent to the Recycle Bin. On the other hand, if you are trying to open a file, you should first make sure the file exists, otherwise the compiler will not be able to open a file it cannot find. To check the existence of a file, the File class provides the Exists method. Its syntax is:
public static bool Exists(string path);
If you provide only the name of the file, the compiler would check it in the folder of the application. If you provide the path to the file, the compiler would check its drive, its folder(s) and the file itself. In both cases, if the file exists, the method returns true. If the compiler cannot find the file, the method returns false. It's important to know that if you provided a complete path to the file, any slight mistake would produce a false result.
The values of the FileShare enumerator are:
FileShare.Inheritable : Allows other file handles to inherit from this file
FileShare.None : The file cannot be shared
FileShare.Read : The file can be opened and read from
FileShare.Write : The file can be opened and written to
FileShare.ReadWrite : The file can be opened to write to it or read from it
Perhaps you could play around with the enumerator and get it to work.
Cheers,
|
|
|
|