|
Yeah, with pointers, unsafe code is a given.
You haven't answered anyones questions about what you're trying to do with this.
There is no such thing as "deleting" with a pointer in C#.
|
|
|
|
|
I'm not sure that you need to, C# has that garbage collection thing. Where it clears memory that's not being used every now and then.
My current favourite word is: Bauble!
-SK Genius
|
|
|
|
|
C# has the garbage collection I agree with you.
But I have to use usafe code. when I turn it on, wil garbage collection still work?
|
|
|
|
|
daavena wrote: But I have to use usafe code. when I turn it on, wil garbage collection still work?
Yes, it will still work. However, remember it is non-deterministic. If you are using pointers into the managed heap you need to make the pointer <a href="http://msdn2.microsoft.com/en-us/library/f58wzh21(VS.80).aspx">fixed</a>[<a href="http://msdn2.microsoft.com/en-us/library/f58wzh21(VS.80).aspx" target="_blank" title="New Window">^</a>] to ensure that garbage collection does not occur on the object you have a pointer to (remember the garbage collection process will also attempt to defragment the heap, so even if the object isn't being collected it may be moved around).
So, once you are finished with your object just ensure it is no longer fixed and allow the managed reference to the memory go out of scope and the garbage collector will get it. If you are encapsulating some piece of native code into a class you may want to look at the IDisposable interface as a way of cleaning up resources when an object of that class is no longer required. This is especially important if the native code did the memory allocation rather than you allocate memory then pass it to the native code.
|
|
|
|
|
C# has the garbage collection I agree with you.
I have to use usafe code, when I turn it on, wil garbage collection still work?
|
|
|
|
|
|
hi (Mouse_OnClick(Object sender,EventArg e))
event i want to display the mouse button which one is been clicked how can i get this...
wasim khan
|
|
|
|
|
MSDN clearly explains it on the Control.Click page... (assuming you use .NET 2.0 or better)
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
I've problem, which is when I click my save button inactive textboxes don't get the latest value (set by javascript function) but the value with which they were loaded...
For example I have a textbox with value 5 after pageload then I use my javascript function onblur and it sets textbox value to 2 and I click Save... (or any other button) The textboxvalue is 5! How can I avoid it in the simplest way to get proper values after postback?
Please help.
|
|
|
|
|
Can anybody help? I know that maybe this problem is trivial, but I've searched the net and found only that using javascript might help... accessing hidden field with javascript... If only anybody knew the steps to do it I would be very grateful...
|
|
|
|
|
Hello, everyone.
I'm hoping this is the right place to post my question. I've been looking around on the net for the last couple of hours and haven't found a solution to my problem. (I did learned some new stuff for use in the future). So this is my situation. I have a program that lets the user create a response test using a movie. When I tried to draw on the movie the activeX controller always pushed its way to the front. So I've created a separate form that floats on top of the main form to draw on. The program also has three threads running, the main thread, a timing thread, and a thread that updates the floating form.
My problem is when I try and send a message to the floating form I trip a NullReferenceException. I've checked both the callback and my class, and both look properly initialized. The floating form is also correctly intialized. I've tried everything I could find, but nothing helps. I've included the method and the callback declaration. The floating form is called 'TestViewer' and the 'HOTSPOT' class is one I've created.
Thanks everyone for your help.
(Sorry my code is in C++, but I know most people us C# or VB when programming in .net, and a lot more people frequent this form than the managed C++ one. If needed I can translate it into C#. Feel free to give me an answer in C#. Over the years I've gotten pretty good a translating C# to C++. Thanks.)
delegate System::Void SetDrawActivePanelCallback(HOTSPOT^ hSpot);
private: System::Void SetTestViewDrawActivePanel(HOTSPOT^ hSpot)
{
if(this->TestViewer->InvokeRequired)
{
SetDrawActivePanelCallback^ cb = (gcnew SetDrawActivePanelCallback(this,
&Edit::SetTestViewDrawActivePanel));
try
{
this->Invoke(cb, hSpot);
} // End try
catch(System::NullReferenceException^ e)
{
String^ s = e->ToString();
::MessageBox::Show(s);
} // End catch
} // End if
else
{
System::Windows::Forms::Panel^ panel = hSpot->GetPanel();
this->TestViewer->DrawActivePanel(panel, this->hotspotVisible);
} // End else
} // End SetTestViewDrawActivelPanel
|
|
|
|
|
There is a message board for C++/CLI questions.
|
|
|
|
|
hi
i try to run my Program on PPC and i get this error:
Can't find PInvoke DLL sqlceme53.dll
what can it be ?
|
|
|
|
|
It must surely mean you're missing SQLCEME53.dll on your machine?
p.s. next time, use a specific, concise subject line. You'll get more responses.
|
|
|
|
|
HI,
i've got a logic Q.
i need to build two stations
station 1 :
1. gathers info from user (in the gui) and send it to station 2
2. listen to msg coming from station 2 in response to the info sent
(station 2 will not responed until all the info from atstion 1 is sent).
station 2 :
1. receive info from station 2 and store it.
2. response for each peace of info (it colud be anything).
how should i implement it?(a general concept with object names would be nice)
can anyone give suggestion??
THNKS in Advance
Have Fun
Never forget it
|
|
|
|
|
hi,
i take one data set using ado.net(sql server 2000), i take one crystal reporti,that is name is crystalreportTest,its file path is c:\Test\CrystalReportTest.rpt,my web application in c:\Test,
my dataset name is DataSetTest,i use this dataset in my crystal Report,i take crystalviewer1 & set the report source which is CrystalReportTest.rpt,
following code are used for solve the login problem(in crystalviewer property i remove logon prompt properties)
my code is as follows-----
using CrystalDecisions.CrystalReports.Engine.Migration ;
using CrystalDecisions.Shared;
using CrystalDecisions.Shared.Interop;
using System.Data.SqlClient;
using CrystalDecisions.Web;
using CrystalDecisions.Enterprise;
using CrystalDecisions.ReportAppServer;
using CrystalDecisions.Reporting.WebControls;
using CrystalDecisions.ReportSource;
using CrystalDecisions.CrystalReports;
using CrystalDecisions.Web.Services;
public partial class _Default : System.Web.UI.Page
{
TableLogOnInfo crTableLogOnInfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
CrystalDecisions.CrystalReports.Engine.Database crDatabase;
CrystalDecisions.CrystalReports.Engine.Tables crTables;
CrystalDecisions.CrystalReports.Engine.Table crTable;
CrystalDecisions.CrystalReports.Engine.ReportDocument crReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
protected void Page_Load(object sender, EventArgs e)
{
crConnectionInfo.ServerName = "SERVER";
crConnectionInfo.DatabaseName = "RESERVATION";
crConnectionInfo.UserID = "sa";
crConnectionInfo.Password = "sa";
crDatabase = crReportDocument.Database;
crTables = crDatabase.Tables;
crReportDocument.Load(@"C:\Test\CrystalReportTest.rpt");
for (int i = 0; i < crTables.Count; i++)
{
crTable = crTables [i];
crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo =crConnectionInfo;
crTable.ApplyLogOnInfo(crTableLogOnInfo);
crTable.Location = "RESERVATION.dbo." + crTable.Location.Substring(crTable.Location.LastIndexOf(".") + 1);
}
CrystalReportViewer1.ReportSource = crReportDocument ;
}
}
<\pre>
i use ReportDocument because in my application crystal report object is not set,when run my code it shows Invalid report file path.i don't know what is happinning ,i have done lot of research on it but i don't find the right solution,i don't know what is my mistak when i run this code ,plz help me anybody
thank you very much for your support
</\pre>
asp.net using c#
|
|
|
|
|
Hi Guys,
I need to create an Application in C#/ASP.NET (in Server1), which can create an Website in SharePoint 2007 (in Server2). Both C#/ASP.NET Application & Sharepoint 2007 are in different Servers.
Please send me information regarding this.
thank you
Mohamed Nazeem
Software Engineer
Bangalore
|
|
|
|
|
Hello friends,
I have a System.AccessViolationException issue that occurs since Vista. On XP's or previous, everything run fine. To be more specific. I have a C++ ATL/COM interface that is wrapped in C# .NET 2.0 . Problem occurs when handling Strings.
I've created COM using standard tools in VS 6.
this is the method definition from Interface IDL file :
[id(9), helpstring("method GetString")] HRESULT GetString([out] LPSTR* word, [out, retval] int* count);
Inferface .h Header file :
STDMETHOD(GetString)( LPSTR* word, int* count);
Code Inferface.c file :
STDMETHODIMP CLicenser::GetString(LPSTR* word, int *count)
{
*count = this->helperClass.GetCount();
*word = this->helperClass.GetWord();
cout << "word:" << *word << endl;
return S_OK;
}
Method definition in C# wrapper looks like:
int IClassNameObject.GetString(out string);
Anytime this method is called, it finishes properly (also including that Console output word:[whatever word contains]) but in Vista, it throws that System.AccessViolationException with name of that (GetString) method after it finishes.
Method is Supposed to return a count and fill a supplied string.
If u need I can create sample project / dll , I don't have one now....
zilo
|
|
|
|
|
Hi, I am making a project that stores information about employees. It has a hidden radio button that when you click delete it checks rbNotEmployee. This is hidden from the user but its important becasue I dont want to delete the record from the database and I dont want to remove it from the listbox. I want that name to show up red in the list box.
I have this so far.
private void lstContacts_DrawItem(object sender, DrawItemEventArgs e)
{
e.DrawBackground();
Brush myBrush = Brushes.Black;
if (rdNotEmployee.Checked == true)
{
myBrush = Brushes.Black;
}
else
{
myBrush = Brushes.Red;
}
/* switch (e.Index)
{
case 0:
myBrush = Brushes.Red;
break;
case 1:
myBrush = Brushes.Orange;
break;
case 2:
myBrush = Brushes.Purple;
break;
}*/
e.Graphics.DrawString(((ListBox)sender).Items[e.Index].ToString(),
e.Font, myBrush, e.Bounds);
e.DrawFocusRectangle();
}
How do I make it that it checks if rbNotEmployee is checked (red) or rbEmployee is checked (black). Thanks for your help in advance.
Kyle
Kyle Maldonado
|
|
|
|
|
I need to change the icon of the resulting .exe for my application programmatically at runtime. The path to the icon will be read form a file. I know it's possible to change the icon through: Project >> Properties >> Common Properties >> General >> Application Icon. I was reading at msdn to find the answer. It seems possible to change it but I just couldn't understand how. If anyone has done this before any help would be appriciated.
I'm using Microsoft Visual Studio .NET 2003 and .NET version 1.1
|
|
|
|
|
If you look in the code that the designer generates you should see the statement that sets the icon, use that.
|
|
|
|
|
Doesn't seem that changes made in project properties are written to the designer generated code as far as I can tell.
|
|
|
|
|
Anyone pls help?
-- I've built an application that would deal with own associated files.., had done providing default icons, file type, and etc. Everything works well by clicking or selecting a single file, my application runs and accepts the parameter which is the full path of the file itself..., but the problem is, when i try to load multiple selected files, when i do that, multiple instances of my application starts each having a single file to open... Though i'm using a string array in the main function of the application, it just loads a single parameter not an array of parameters..., I've used functions to access the registry, and used "%1" as an Argument, so maybe that could be the main problem....
-- Is there anyway i could change this to other values to attain multiple file entries with one instance of my application? Such as Windows Media Player enlisting all files when you use Ctrl+A in a directory of music files...,
----Thanks a lot in advance!!!!
|
|
|
|
|
Perhaps you could acquire a mutex with the first instance of your application. Then, successive attempts to open a duplicate of your application would see that the mutex is already acquired (meaning you have 1 instance of your app already running), and you could send the file path to that instance, then exit the new one. Hope this helps,
-Jeff
|
|
|
|
|
I'm sorry, can you pls elaborate? M not sure i got it...
===sorry, just a little of a beginner man(Jeff).
|
|
|
|