|
thanks but i dont even knw where to place this code..
plz tell me.
|
|
|
|
|
You can put it , at your Form Load Event !
I know nothing , I know nothing ...
|
|
|
|
|
thanks
|
|
|
|
|
Hi All,
I have a object with values and want to copy it in other object(which has same propery of source).
Please help me with this.
Ramkumar
("When you build bridges you can keep crossing them. ")
http://ramkumarishere.blogspot.com
|
|
|
|
|
If both objects are of the same type you want to implement the IClonable Interface. Just be aware that the example uses the MemberwiseClone method which is great for value types but doesn't copy reference types (only the pointer gets copied)
"You get that on the big jobs."
|
|
|
|
|
If you need a shallow copy ie two references to same object, then just equate them. If you need a deep copy ie new object with same values, you use reflection (will be slow) or you can use MemoryStream and BinaryFormatter to do this. If you search google for creating deep copy, you can find lot of examples to do this.
|
|
|
|
|
Hi,
I am using visual c# 2010 express.
All of a sudden I get this error when I try to open the designer of the form.
The class name '?' is not a valid identifier for this language.
Note that the solutin compiles successfully.
I have chedked for '?' but there is none.
Any thoughts please? thanks
Detailed error is below:
Instances of this error (1)
1. Hide Call Stack
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomParser.CodeTypeDeclarationFromCodeClass(CodeClass vsClass)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomParser.Parse(TextReader codeStream)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.MergedCodeDomParser.System.CodeDom.Compiler.ICodeParser.Parse(TextReader stream)
at System.CodeDom.Compiler.CodeDomProvider.Parse(TextReader codeStream)
at Microsoft.VisualStudio.Shell.Design.Serialization.CodeDom.CodeDomDocDataAdapter.get_CompileUnit()
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.DeferredLoadHandler.Microsoft.VisualStudio.TextManager.Interop.IVsTextBufferDataEvents.OnLoadCompleted(Int32 fReload)
|
|
|
|
|
|
|
Hello code project members,
I have a strange problem with the IBasicVideo interface when using GetCurrentImage. The image is grabbed correctly from the video stream (avi/mpeg4) but a band of 10 pixels which should be at the right edge of the image is placed to the left side.
You can view a test image which shows the problem under -> Test.jpg
Here is the code I use:
m_pBasicVideo.GetCurrentImage(ref buffSize, zero);
IntPtr tempBuffer = Marshal.AllocHGlobal(buffSize);
m_pBasicVideo.GetCurrentImage(ref buffSize, tempBuffer);
bmpHeader = new BitmapInfoHeader();
Marshal.PtrToStructure(tempBuffer, bmpHeader);
bmp = new Bitmap(bmpHeader.Width, bmpHeader.Height, bmpHeader.ImageSize / bmpHeader.Height, System.Drawing.Imaging.PixelFormat.Format32bppRgb, tempBuffer);
I did some google research the last few hours but can't find anything that could solve my problem. Hope you guys can give me some enlightenment.
Thanks
Marcus
|
|
|
|
|
Your pixel stream is offset, causing the "new lines" to occur at the wrong place; actually you are using the same value of tempBuffer twice.
In
Marshal.PtrToStructure(tempBuffer, bmpHeader);
you claim it points to the header, which I assume is correct.
However in
bmp = new Bitmap(bmpHeader.Width, ..., tempBuffer);
you claim it points to the pixel data, which is probably wrong. Seems you need to add the header's size to the pointer before passing it to the bitmap constructor.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Add 40 to tempBuffer in last line.
...System.Drawing.Imaging.PixelFormat.Format32bppRgb, tempBuffer + 40);
|
|
|
|
|
I'm trying to convert parts of a VB6 program to C#. But I have stumbled over a set of instructions I cannot directly convert.
Here is the VB code:
Winsock_Search.SendData Chr$(0) & Chr$(0) & Chr$(0) & Chr$(&HF6)
Winsock_Seach is just a windows socket, so never mind that. But my problem is:
Chr$(0) & Chr$(0) & Chr$(0) & Chr$(&HF6)
How do I convert that to C# code?
|
|
|
|
|
Winsock_Search.SendData("\0\0\0" + ((char)246).ToString());
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
|
Its simple to lookup what the Chr$ method does in VB, then you will know to use ToChar() in .NET
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
The technically proper translation is:
Winsock_Search.SendData(Strings.Chr(0) + Strings.Chr(0) + Strings.Chr(0) + Strings.Chr(0xf6)); But you will have to add a reference to Microsoft.VisualBasic.dll to use it.
I would go with JSOP's solution, with a minor change:
Winsock_Search.SendData("\0\0\0" + ((char)0xF6).ToString()); or
Winsock_Search.SendData("\0\0\0\xF6");
If you have difficulties with translation VB <=> C#, there is a good online converter here[^] - I use it to answer VB questions.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
I have a window application in which I am trying to load a web configuration
but i get is not a valid virtual path error.
I am trying to encrypt any web config file from window application
System.Configuration.Configuration config = WebConfigurationManager.OpenWebConfiguration(filepath);
ConfigurationSection section = config.GetSection("connectionStrings");
if (section != null)
{
if (!section.IsReadOnly())
{
section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");
section.SectionInformation.ForceSave = true;
config.Save(ConfigurationSaveMode.Full);
}
}
can anyone tell me how can i load a web config.
|
|
|
|
|
Why don't you just load the file as a text file, and exncrypt the resulting string?
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
We could do that but we are using data block of enterprise library and using this encryption it works fine but not with other encryption
|
|
|
|
|
As I've understand it the callback method specified in the Timer constructor can be executed multiple times in parallell. It does not wait for the callback to finish.
This can cause issues for me so I need to be sure that only one callback (or the task it will perform) will run one at a time and if the task suceeds the timer must stop. How can I do that? Will the following do the job?
System.Threading.Timer timer;<br />
private void StartThreadTimer()<br />
{<br />
timer = new System.Threading.Timer(TimerCallback, "hepp", 0, 5000);<br />
}<br />
<br />
void TimerCallback(object callbackObj)<br />
{<br />
if (Monitor.TryEnter(lockerObject))<br />
{<br />
try<br />
{<br />
Thread.Sleep(1000);
timer.Dispose();
}<br />
finally<br />
{<br />
Monitor.Exit(lockerObject);<br />
}<br />
}<br />
}
If the above is not safe enough, how should I do it?
Thanks!
|
|
|
|
|
System.Threading.Timer timer;
private void StartThreadTimer()
{
timer = new System.Threading.Timer(TimerCallback, "hepp", 5000, Timeout.Infinite);
}
void TimerCallback(object callbackObj)
{
Thread.Sleep(1000);
if (!success) {
timer.Change(5000, Timeout.Infinite);
}
}
I would use a single shot timer and restart it in the callback if the task is not successful. This way the callback can never be reentered and the lock isn't needed.
Alan.
|
|
|
|
|
Be a man, and use threads instead. Timers are for people that are closet VB programmers.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
I'm just curious: How would you achieve what I'm after with a separate thread? I like the idea but they're scary
Would I just use Thread.Sleep in that thread instead of a timer?
Thanks!
|
|
|
|
|
Using threads requires more code, but they're a lot more flexible than timers. That, and the fact that Toimer events in Windows are the lowest priority events, and on a busy system, they're not guaranteed to be fired. That means there's a certain lack of reliability, and that's a "Bad Thing" (TM).
Before committing to using threads in a production app, you should create some test apps and get used to the idea of them. There are a lot of good articles reagarding the use of multithreading here on CodeProject.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|