|
Thanks!
it worked!
But (there is always a but...),
before that I created a loading function that supposed to update a listbox from that serializing, so now I'm getting an exception over there (System.Reflection.TargetInvocationException), and I really don't understand why, everything looks great!
this is the code of that function:
public void UpdateList()
{
serialize load = new serialize();
Stream stream = File.Open("text.sav", FileMode.OpenOrCreate);
BinaryFormatter bformatter = new BinaryFormatter();
try
{
load = (serialize)bformatter.Deserialize(stream); //THIS LINE GETS THE EXCEPTION.
for(int cnt = 0 ; cnt < lbList.ItemHeight ; cnt++)
lbList.Items.Add(load.strText[cnt]);
}
catch(System.Runtime.Serialization.SerializationException)
{
MessageBox.Show("System.Runtime.Serialization.SerializationException");
}
catch(System.ArgumentNullException)
{
MessageBox.Show("System.ArgumentNullException");
}
stream.Close();
}
Thanks alot in advance!
|
|
|
|
|
hi, i am writting a c# windows project, i want to call a java class throgh it, so any one can help me to be able to call java class through my project to be able to use the functions sttored in this java class
Thanks alot
Hamody
|
|
|
|
|
Java converts easily to C#. If you need to call code in an existing app, I'd guess you are screwed. Perhaps J# can help, somehow ? I'm thinking Java uses CORBA, perhaps J# does too, and can be interoped to C# as well.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hi, thanks alot, but could you please tell me how i can change the code written in java to c# easily as you said.
regards,;)
Thanks alot
Hamody
|
|
|
|
|
Mohammad Bassam Daba`an wrote:
could you please tell me how i can change the code written in java to c# easily as you said.
One line at a time. Seriously, I've converted a bit of java to C#, and it's dead easy, they are virtually the same, even the support libraries are similar.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
SqlCommand cmd=new SqlCommand();
cmd.Connection=con;
cmd.CommandTimeout=35000;
cmd.CommandText="SAging";
cmd.CommandType=CommandType.StoredProcedure;
Application.DoEvents();
cmd.ExecuteNonQuery();
I use the code like above code to run stored procedure.before this process finished,i open another application,my form show not responding..even i put
Application.DoEvents(),it not work..how can i control stored procedure process.Pls guide me.
|
|
|
|
|
kyawsoe wrote:
my form show not responding
While the command is executing your application is blocked...
kyawsoe wrote:
cmd.CommandTimeout=35000;
...for upto 9.7 hours!
If you want your application to be responsive while the query is running you will have to run the query in a new thread.
NOTE for people migrating to .NET 2.0. The ADO.NET 2.0 contains built in asyncronous querying so that you don't have to set up a separate thread yourself as the .NET framework will do it for you.
My: Blog | Photos | Next SQL Presentation
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
i can not understand how to use dataadapter to fill a datagrid without using code behind
|
|
|
|
|
I suppose this[^] is a more appropiate forum.
Unless of course, you are talking about a Windows Forms DataGrid , but then code behind doesn't make sense.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Hi everyone,
I am hoping to build a C# application that would interact with Outlook Express 6 and xtract attatchments under my identity to a specific folder. In between this process it would have to check if the attatchment is already saved in the folder, but those tasks would be possible with the IO classes of the .NET framewrk. But how about getting into the Outlook program ? How do I handle that ? Is there a COM object that ships with OE6 or are there free .NET libraries to access OE's object model ?
I searched the web and all i could find was code snippets and articles relating to the office version of Outlook.
Please explain how i should handle this solution or give me some links to any web resources.
Thanx a lot !
|
|
|
|
|
erajsri wrote:
there free .NET libraries to access OE's object model ?
They could only access it if the COM objects exist. My guess is that they don't.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi all
My Error is " Cannot implicitly convert type 'object' to'CIODMLib.CatAdmClass' "
The code segment is as follows;
public class Indexing
{
protected CIODMLib.AdminIndexServerClass admNew;
protected CIODMLib.CatAdmClass catNew;
public Indexing()
{
admNew = new CIODMLib.AdminIndexServerClass();
catNew = new CIODMLib.CatAdmClass();
}
public object InitializeCatalog(string strName, string strLoc)
{
admNew.AddCatalog(strName, strLoc);
return admNew.GetCatalog();
}
public void AddNewScope(string strName)
{
catNew = admNew.GetCatalogByName(strName);
}
}
public class IndexingAp
{
public static void Main(String[] args)
{
Indexing newAdm = new Indexing();
Indexing newCat = new Indexing();
newAdm.InitializeCatalog("myCat","C:\\myCatalogFolder");
newCat.AddNewScope("myCat");
}
}
I even tried
"catNew = (CIODMLib.CatAdmClass)admNew.GetCatalogByName(strName);"
Then error "'System.InvalidCastException' occurred Specified cast is not valid." occurs
Can some one please help me???
|
|
|
|
|
try object o = admNew.GetCatalogByName(strName);, then step through in the debugger to see what you're getting back. Perhaps it's null.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I guess GetCatalogByName is not returning a type that can be cast to CIODMLib.CatAdmClass . As CG said, try running it under the debugger or add a
System.Diagnostics.Debug.WriteLine((admNew.GetCatalogByName(strName)).GetType().ToString());
to see what exactly it is returning.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
hi all,
I want to synchronize client and server databases using C# application..
How do i do it?
any answers will be appreciated.
thanks in advance..
|
|
|
|
|
What is the state of the databases before hand ? Do you know the schema ? Do both databases exist ? Can you write whatever stored procedures you like on these databases ? The easiest thing would be to drop all foreign keys and so on, then copy the data across, a table at a time, and finally readd the constraints. But I'm also assuming you only need to syncronise data.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I have a richtextbox with the following event handler for the ContentsResized event. The richtextbox Multiline property is set to true and the Scrollbars property is set to none.
The problem I have is when typing in lines of text. The first line dissappears (scrolls) above the top of the richtextbox. Other than that the richtextbox resizes itself accordingly.
Can anyone please help me rectify this problem? Am I using the correct method? Is there a better way to do it?
The code for the event handler:
private void ContentsResized(object sender, System.Windows.Forms.ContentsResizedEventArgs e)
{
// Create a new object that refers to the control that fired the event
RichTextBox richBox = (RichTextBox)sender;
Font stringFont = richBox.Font;
string queString = richBox.Text;
System.Drawing.Graphics objGraphics;
objGraphics = CreateGraphics();
SizeF layoutSize = new SizeF(richBox.Width, ClientRectangle.Height);
SizeF stringSize = new SizeF();
stringSize = objGraphics.MeasureString(queString, stringFont, layoutSize);
richBox.Height = Convert.ToInt32(stringSize.Height);
objGraphics.Dispose();
resetPositions();
}
|
|
|
|
|
Hello, guys
I got a problem of calling class methods from C++ dll in my C# program.
My old dll is standard C++ dll. For non-class methods, I decorate the method with:
extern "C" _declspec(dllexport)double myMethod(double b, double h);
Then I can use the following to call the method foo in C#.
[DllImport("my.dll")]
public static extern int foo();
But if it is a class, I use the following syntax to decorate it:
class __declspec(dllexport) myClass{
... ...
}
But this time, I don't know how to it and .NET throws exception of "Additional information: Unable to find an entry point named fndllclasstest1 in DLL my.dll".
Could anyone help me figure out how to call class method from a standard dll in C# applications?
Many thanks
Ivyhill
|
|
|
|
|
go to command prompt where your dll is located.
type: dumpbin -exports xxx.dll
you might get something like this
1 0 00001B60 ?Foo@@YAXXZ
with some other data. The data above is your exported function from your c++ dll.
Next step is to get the function.First, you need this line to interoperate between your c++ dll and c#
using System.Runtime.InteropServices;
Then this is how you call your function by setting the entry point to the information given.
[DllImport(@"cntr.dll", EntryPoint="?Foo@@YAXXZ", CallingConvention=CallingConvention.StdCall, SetLastError=true)]
public extern void Foo();
that's all you need.
|
|
|
|
|
Thanks Mervick. It works.
|
|
|
|
|
I have the following two chunks of code:
1)
NetworkStream networkStream = new NetworkStream(member.socket);
System.IO.StreamWriter streamWriter = new System.IO.StreamWriter(networkStream);
...
2)
NetworkStream networkStream = new NetworkStream(s);
System.IO.BinaryWriter bw = new System.IO.BinaryWriter(networkStream);
...
What would be the order for closing the streams and flushing? And do I need to do both on both the client and server side?
IE:
1)
streamWriter.Flush();
streamWriter.Close();
networkStream.Flush();
networkStream.Close();
2)
bw.Flush();
bw.Close();
networkStream.Flush();
networkStream.Close();
Thanks
|
|
|
|
|
You don't need to close the NetworkStream after closing the StreamWriter , the StreamWriter does it for you. MSDN says "Closes the current StreamWriter and the underlying stream". And closing the StreamWriter flushes it, so you don't need to Flush<code> before <code>Close
In short, all you need is
streamWriter.Close();
And you must close it both on the client and the server, each end creates some resources that must be released by calling Close .
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thanks.
|
|
|
|
|
I've 2 forms i want set a text inside the second form by the first one.
If i try i get a compiler error about permissing, the object (textbox is private).
What i heve to do?
|
|
|
|
|
hi,
can you change class where is your textbox private ? If so you can change textbox's modifier to public (not recommended) or internal (better) or you can write property for setting/getting value of textbox (recommended).
public means that everybody can directly change textbox's value - that's not good idea. internal means that everybody (classes) in same assembly can change textbox's value - that can be useful in some scenarios. By writing (public) property, you gain control over how and when can value change... e.g. you can have test for valid format of string or something and change actual value only if it's format is ok...
hope it helps
David
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|