|
Is there a quick way of retrieving the hearder from an RTF?
thx
Nana
|
|
|
|
|
I was Testing my program, which is a thread/database intense program. I ran it in VS, and it runs perfectly and all of a sudden gives me a popup box with this message:
Managed Debugging Assistant 'RaceOnRCWCleanup' has detected a problem in 'C:\Documents and Settings\Wallace\My Documents\Visual Studio 2005\Projects\Visual Waiter\Visual Waiter\VWServer\bin\Debug\VWServer.vshost.exe'.
Additional Information: An attempt has been made to free an RCW that is in use. The RCW is in use on the active thread or another thread. Attempting to free an in-use RCW can cause corruption or data loss.
What does this mean? whats RCW?
It looks like to be that everytime this message pops up, the program is stopped at
dbConnection.Close();
Maybe I am closing the connection somewhere else? so i have 2 .Close() somehow causing race condition?
I used threadpool in my prgoram to handle the threads, it seems like that it is only running 2 threads at the same time. I hope there is a property i can set in Threadpool that i can increase the amount of concurrent running threads??
-- modified at 15:37 Thursday 19th January, 2006
|
|
|
|
|
2hdass wrote: Maybe I am closing the connection somewhere else?
It actually sounds like your trying to close a connection that still had a query pending. Perhaps your opening a connection on one thread and running a query on that connection on another thread???
RCW stands for Runtime Callable Wrapper. It's the wrapper code that your .NET Managed code calls to get at unmanaged COM code, like controls or libraries.
There is no property to increase the number of concurrently runnable threads. What may be limiting the number of threads is whatever your calling in those threads. Like the SQL server your connecting to doesn't have any more connection licenses? Or the server your connecting to doesn't have any more open connections?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
So how can we avoid This RCW error being thrown from that dll while calling them from another .net application via multithreading??
can we pls reply asap??
|
|
|
|
|
Write better code?
How did you expect me to answer that? There are so many ways of writing database access code and even more ways of doing it wrong it's impossible for anyone to guess at what you're doing and how you're doing it.
About the best I can do is tell you that your database code should follow a pattern: Open the connection to the database as late as possible, do your database work as quickly as possible, then close the connection as early as possible. Do not open a connection as part of a class to make it visible anywhere within the class. You will have less control over the lifetime of the connection.
|
|
|
|
|
I've got a project in VS2003 where I've added a number of images and a video clip as an embedded resource on 'Build Action'. I can access the images easy enough by using the following code:
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(GetType(), "sampleImage.jpg"); this.pictureBox1.Image = bitmap;
The problem is accessing the embedded .AVI; both the ActiveX Windows Media Player and the DirectX AudioVideoPlayback require a string pointing to a file?
Accessing Video File Thru ActiveX Windows Media Player Control:
private AxWMPLib.AxWindowsMediaPlayer axWindowsMediaPlayer1;
this.axWindowsMediaPlayer1.URL = "sampleVideo.avi";
Accessing Video File Thru DirectX 9:
using Microsoft.DirectX.AudioVideoPlayback;
Video vid = new Video("sampleVideo.avi", false);
Any help would be greatly appreciated.
"She folds her legs...in doing so I glimpse Xanadu."--Gilby
|
|
|
|
|
Hi,
I want to do some actions immdiately after the form load automatically.
How do I do it. If I do in form load then it happens before the form is loaded. But I want to do after the form is loaded.
How do I do it..Thanks.
|
|
|
|
|
Hi!
One solution could be to attach an event handler for Application.Idle in the Load event handler and then perform your work there:
private void myForm_Load(object sender, EventArgs e)
{
Application.Idle += new EventHandler(app_Idle);
}
private void app_Idle(object sender, EventArgs e)
{
Application.Idle -= new EventHandler(app_Idle);
MessageBox.Show("This happens almost immediately after myForm_Load has returned!");
} Regards,
mav
|
|
|
|
|
|
Or if you're using .net 2
myForm.Shown += formStartup;
void formStartup(object sender, EventArgs e)
{
}
|
|
|
|
|
Perfectly working. Thanks a lot.
|
|
|
|
|
I'm working on a project with some pretty math intensive calculations that must output double values. After much testing, it was determined that we have an accuracy out to 10 digits after the decimal point. This is adequate for what I'm working with so we kept going forward.
Now, in the next phase of the project, comparisons have to be made between two structures that contain the double results, so I overloaded Equals() to do a comparison to the tested accuracy. Immediately I found some big problems with this. Because of the way Equals() is determined, I run into the problem where the following is true: A==B, B==C, A!=C. I'm a bit stumped on how to fix this. There must be a way, but I'm not really seeing anything.
I created the following test code to illustrate my problem:
using System;
using System.Collections;
namespace TestIt
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
SomeStruct val1 = new SomeStruct(1.0);
SomeStruct val2 = new SomeStruct(1.0);
SomeStruct val3 = new SomeStruct(1.00000000009999);
SomeStruct val4 = new SomeStruct(0.99999999999);
Console.WriteLine("Starting . . .");
if (val1.Equals(val2))
Console.WriteLine("val1 == val2");
if (val2.Equals(val3))
Console.WriteLine("val2 == val3");
if (val1.Equals(val3))
Console.WriteLine("val1 == val3");
if (val1.Equals(val4))
Console.WriteLine("val1 == val4");
if (val3.Equals(val4))
Console.WriteLine("val3 == val4");
Console.WriteLine("Done");
}
public struct SomeStruct
{
private static double accuracy = 0.0000000001;
public double Value;
public SomeStruct(double val)
{
Value = val;
}
public override bool Equals(object obj)
{
if (obj is SomeStruct)
return (Math.Abs(Value - ((SomeStruct)obj).Value) < accuracy);
return false;
}
}
}
}
Anyone have any ideas?
-----
In the land of the blind, the one eyed man is king.
|
|
|
|
|
I think you will find val3 - val4 is greater then accuracy . The program is working as written.
You will have to change the value of accuracy to get the results you want. If you want to use accuracy as defined, you may want to truncate all your numbers to 10 digits before testing for equality.
Take a look at double.Epsilon . It contains a number you can use to test for equality on doubles but, it carries it to the least significant digit.
Also, take a look at the Decimal structure. It may suit your needs out of the box.
|
|
|
|
|
Yes, val3 - val4 is greater than accuracy, but that leaves me with the problem that val3 == val1 is true, val1 == val4 is true, but val3 == val4 is false. A==B, B==C therefore A==C is a basic mathematical principal that this is breaking, and I'm afraid will cause problems, and I can't figure out a way around it.
Truncation isn't quite right either, that way 1.0000000001 and 1.00000000009 wouldn't match up.
I've since rewritten the equality method, to get much better results but no matter how I change it, I still can't get around that basic problem.
BTW, I've thought about using the Decimal structure for internal calculations, but I don't know how much it would gain me when most of the intermediate results will be stored outside of my class and will be in double.
-----
In the land of the blind, the one eyed man is king.
|
|
|
|
|
You will get better results if you round each value and then compare them, instead of checking the sum of the rounding errors.
Math.Round(this.Value, 10) == Math.Round(((SomeStruct)obj).Value, 10)
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
I have table with 2 columns
----------------------------------
DataSet dsABC = new DataSet();
dsABC.Tables.Add("ABC");
dsABC.Tables[0].Columns.Add("NAME",typeof(string));
dsABC.Tables[0].Columns.Add("AGE",typeof(int));
---------------------------------------------------
I am have a problem extracting the data from the columns ....
While I am doing
int Age = dsABC.Tables[0].Rows[0]["AGE"];
It says "Cannot implicitly convert type 'object' to 'int'".
Is there any way can we assign datacell to an int with out using Conver.Int32
Thanks And Regards,
Subbu
|
|
|
|
|
The only way I know of is to used typed datasets. They can be kind of a pain to setup (if you end up doing it manually, like I needed to for a recent project), but they are MUCH nicer to work with.
I don't have a link off hand, but I'm sure there's an article about them here on code project or MSDN.
-----
In the land of the blind, the one eyed man is king.
|
|
|
|
|
Hi,
Thanks for ur Information.
Can u give me any example which does manually.
I have gone through lots of sites ..I could not get a good example which creates Typed dataset manually
Thanks and Regards,
Subbu
|
|
|
|
|
int Age = (int)dsABC.Tables[0].Rows[0]["AGE"];
|
|
|
|
|
Thanks for ur information
But what is the point of declaring AGE column as of type "int" while defining the table.
|
|
|
|
|
Hi,
I like to wrap all controls before I use it in my own projects. It would be usefuel if the wrapped control is still accessible from the outside world. I can define a property on the wrapper and hand out the instance of the wrapped 3rd party control.
public class MyCustomButton
{
private 3rdParty.Controls.Button _button;
public 3rdParty.Controls.Button WrappedButton
{
get
{
return _button;
}
}
}
This way one is able to access programmatically. But if one changes something in the visual designer, the changes made on the wrapped control are lost, because they aren't written down by the designer into the IntitalizeComponents() method.
Is there any way to tell the designer to store the init settings for the wrapped control as well?
Thanks
myMsg.BehindDaKeys = "Jerry Maguire";
-- modified at 13:05 Thursday 19th January, 2006
|
|
|
|
|
I'm have to get (image)files at runtime in your slideshow viewer, so they can be displayed in the viewer.
The photos are first being displayed with a string that tells you were the file is located. When I push on the Add-button, the photo must be shown in the viewer.
Does anyone knows how to do that, it would be really helpfull...
thx
|
|
|
|
|
Hello guys,
I am having here some problems regarding pc's where the RPC server is not running or pc's where the windows firewall is causing my program to crash.
I am doing some inventories with WMI queries. Most of them it is not a problem, but there are PC's were the windows firewall is on and giving me the following error (from the log file):
DISCOVERY Error, sComputerType, System.Runtime.InteropServices.COMException: De RPC-server is niet beschikbaar. (Exception from HRESULT: 0x800706BA)
After 4 of this errors my program quits, altought that I am using Try Catch.
Is there a way to check if the 'RPC server is available' prior to the inventory process?
Thanks in advance.
The code for your info:
<br />
public static string GetInfoWithWMI(string _sComputerName, string _sParameter, string _sObjName, string _sObjQuery)<br />
{<br />
string sComputerName = _sComputerName;<br />
string sParameter = _sParameter;<br />
string sObjName = _sObjName;<br />
string sObjQuery = _sObjQuery;<br />
string sValue = "";<br />
<br />
try<br />
{<br />
ManagementScope scope = new ManagementScope("\\\\" + sComputerName + "\\root\\CIMV2");<br />
scope.Connect();<br />
ObjectQuery query = new ObjectQuery(sObjQuery);<br />
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);<br />
<br />
foreach (ManagementObject queryObj in searcher.Get())<br />
{<br />
if (queryObj[sObjName] != null)<br />
sValue = queryObj[sObjName].ToString();<br />
}<br />
if (Program._LoggingEnabled == "Y" && Program._LogDiscoveryProcess == "Y")<br />
Program.LogInfo("Discovery process: object=" + sComputerName + ", " + sParameter + "=" + sValue, 1);<br />
return sValue;<br />
}<br />
catch (System.Management.ManagementException mex)<br />
{<br />
<br />
if (Program._LoggingEnabled == "Y" && (Program._LogDiscoveryProcess == "Y" || Program._LogProgramErrors == "Y"))<br />
Program.LogInfo("DISCOVERY Error, " + sParameter + ", System.Management.ManagementException: " + mex.Message, 3);<br />
}<br />
catch (System.Runtime.InteropServices.COMException comex)<br />
{<br />
if (Program._LoggingEnabled == "Y" && (Program._LogDiscoveryProcess == "Y" || Program._LogProgramErrors == "Y"))<br />
Program.LogInfo("DISCOVERY Error, " + sParameter + ", System.Runtime.InteropServices.COMException: " + comex.Message, 3);<br />
}<br />
catch (System.Exception ex)<br />
{<br />
if (Program._LoggingEnabled == "Y" && (Program._LogDiscoveryProcess == "Y" || Program._LogProgramErrors == "Y"))<br />
Program.LogInfo("DISCOVERY Error, " + sParameter + ", System.Exception: " + ex.Message, 3);<br />
}<br />
<br />
return "";<br />
}<br />
|
|
|
|
|
Found a piece of code that should do the job.
<br />
System.ServiceProcess.ServiceController myController = new System.ServiceProcess.ServiceController("Remote Procedure Call (RPC)", sComputerName);<br />
if (myController.Status == ServiceControllerStatus.Running)<br />
sRPC = true;<br />
else<br />
sRPC = false;<br />
Feedback me if you think that is wrong.
|
|
|
|
|
Hello all!
I'm a rookie at C# and i'm wondering why the hell does a new class library project with one function added by me generates a DLL with no functions???
I'm I being very dumb here???
The project only have two classes: AssenblyInfo.cs and Class1.cs
Class1.cs defines a class with one function.
all compiles well but no functions on the DLL!!!!!!
Help!!!!
|
|
|
|