|
I have developed a dll in C#.NET and I have used it in a VB project to make an ocx of it. if I use this ocx in a C#.NET project, there is no problem, but when I use it in the HTML page, it seems that the try-catch of the dll doesn't work, do you have any idea to solve this problem? s
|
|
|
|
|
hi to all,
I want to convert my MS Access databse/table in to an .xml file. How can I do it? help me.
Pravin
|
|
|
|
|
Its simple, read data in all the table and generate xml file...
|
|
|
|
|
can u plz send me example for this. I am new to c#.
Pravin
|
|
|
|
|
You should start with easier tasks if you're new to C#.
|
|
|
|
|
I use these code to generate a xml file(i use SqlServer2005 for the DB), for example:
string MyConn = ConfigurationManager.ConnectionStrings["Connect"].ConnectionString;
SqlConnection conn = new SqlConnection("MyConn");
string SqlStatement = "SELECT * FROM my_table"
SqlDataAdapter adapt = new SqlDataAdapter(SqlStatement,conn);
DataSet ds = new DataSet();
DataTable dt = new DataTable("my_table");
adapt.Fill(dt);
ds.Tables.Add(dt);
ds.WriteXml (@"..\..\myXmlFile.xml")
After that build and execute u'r application.In windows explorer,Locate and Find u'r xml file on u'r project folder..Hope Can Help U
Best Regards,
Tomi
|
|
|
|
|
|
Hi,
I want to save a few arraylist into a file. One method that i found out is to use serializable. However, below is the exception error when i try to save the window form.
Additional information: The type System.Drawing.Drawing2D.GraphicsPath in Assembly System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken.... is not marked as serializable.
The program is able to draw shapes into a panel and it has shape classes(e.g. rect class,polygon class...) in those classes it uses graphicspath to add the shapes onto the panel. besides that, one of the arraylist also contains Graphicspath. I'm able to serialize the arraylist other than those that use GraphicsPath. So, can anybody help me to explain what i should do to solve this problem?
Thanks in advance to anybody who is willing to lend a helping hand
|
|
|
|
|
everything is going to be serialized must have Serializable Attribute in .Net but GraphicsPath class does not have it so you can't direcly Serialize it however there are some ways to do that
I saw a constructor for GraphicsPath Takes 3 arguments (PointF[] points ,byte[] types ,FillMode fillMode)
and of course three Property from GraphicPath instance FillPoints:pointF[] ,PathTypes:byte[] ,FillMode:FillModeEnum
all of these three type are marked as serializable so you can serialize these data and then desrialize them and create a new GraphicsPath instance identical to the Serialized one.
Code some like this
<br />
<br />
[Serializable]<br />
class GraphicsPathData<br />
{<br />
byte[] types;<br />
PointF[] points;<br />
FillMode fillMode;<br />
<br />
public GraphicsPathData(GraphicsPath gp)<br />
{<br />
this.types = gp.PathTypes;<br />
this.points = gp.PathPoints;<br />
this.fillMode = gp.FillMode;<br />
}<br />
<br />
public static System.IO.Stream Serialize(GraphicsPathData gpd)<br />
{<br />
System.IO.MemoryStream ms=new System.IO.MemoryStream();<br />
<br />
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();<br />
<br />
bf.Serialize(ms, gpd);<br />
ms.Flush();<br />
return ms;<br />
}<br />
<br />
public static GraphicsPathData Deserialize(System.IO.Stream stream)<br />
{<br />
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();<br />
<br />
object obj=bf.Deserialize(stream);<br />
GraphicsPathData gpd =obj as GraphicsPathData;<br />
return gpd;<br />
}<br />
<br />
public static GraphicsPath GetGraphicsPath(GraphicsPathData gpd)<br />
{<br />
return new GraphicsPath(gpd.points, gpd.types, gpd.fillMode);<br />
}<br />
<br />
public static GraphicsPath GetGraphicsPath(System.IO.Stream gpdStream)<br />
{<br />
return GetGraphicsPath(Deserialize(gpdStream));<br />
}<br />
}<br />
<br />
and I tested that like
<br />
<br />
GraphicsPath gp = new GraphicsPath();<br />
gp.AddEllipse(10, 10, 100, 100);<br />
<br />
GraphicsPathData gpd = new GraphicsPathData(gp);<br />
System.IO.Stream gpdStream = GraphicsPathData.Serialize(gpd);<br />
<br />
<br />
System.IO.Stream newStream = new System.IO.MemoryStream(((System.IO.MemoryStream)gpdStream).ToArray());<br />
<br />
GraphicsPath gpDeserialized = GraphicsPathData.GetGraphicsPath(newStream);<br />
<br />
Good Luck
|
|
|
|
|
Hey, thanks for the great reply.
However if i got an 3 arraylist to be serialize, one of them is an arraylist containing graphicspath, how do i deserialize them back to the 3 different arraylist. Should i save the number of items in each of the arraylist?
Below is how i put all the arraylist into a single arraylist
ArrayList arr = new ArrayList();<br />
<br />
arr.Add(Arraylist1);
for(int i=0;i<ArrayList2.Count;i++)
{<br />
GraphicsPathData gpd = new GraphicsPathData((GraphicsPath)PathList[i]);<br />
Stream gpdStream = GraphicsPathData.Serialize(gpd);<br />
arr.Add(gpdStream);<br />
}<br />
<br />
arr.Add(Arraylist1);
<br />
formatter.Serialize(myStream, arr);<br />
myStream.Close();<br />
What other method do you suggest?
Thanks in advance
|
|
|
|
|
The thing you are doing is going to work and is ok
and Yes if you are using arrays you must know what data is where
for preventing this you can use HashTable and use Enum or string names for keys
these are wrote down here are just suggestions
how about to create a GraphicsPathDataCollection Class and pass those GraphicsPaths to it and Serialize/ Deserialize the GraphicsPathDataCollection and take back your array of GraphicsPath after Deserializing.
this needs some coding but is the correct way because you have a collection and maybe some other time you simply modify it for other use (like import and export...)
there is an easier way too just like you did, but you can put all your GraphicsPathData inside a ArrayList not their serialized streams then Serialize the Array because as you know serializing is not such a fast job exeptionaly if you use SoapFormatter and in this way lots of resources going to be wasted.
and one another thing if you are using .Net2.0 why we don't use List<> instead of ArrayList if all of our data are the same!.
enum myPhases {gpData /*and other things you need to serialize */};
HashTable tableMustbeSerialized=new HashTable();
List<GraphicsPath> gpList; //your Graphicspaths
List<GraphicsPathData> gpdList=new List<GraphicsPathData>();
foreach(GraphicsPath gp in gpList)
gpdList.Add(new GraphicsPathData(gp));
.
.
.
//other things must be Serialized
tableMustbeSerialized.Add(myPhases.gpData ,gpdList);
.
.
.
//add other Data too
formatter.Serialize(myStream, tableMustbeSerialized);
myStream.Close();
and of course after deserializing it can be easier retrieved
object deserializedObject;
HashTable myData=deserializedObject as HashTable;
List<GraphicsPathData> gpdList=myData[myPhases.gpData] as List<GraphicsPathData>;
if you need help I'm here
good luck
|
|
|
|
|
Hi,
I created a VC++ MFC static Dll and wrote a function with __decl(dllexport).Then I created C# wrapper on top of the VC++ MFC Static DLL and tried to call the method in wrapper DLL through a sample windows application in C#.But i could not proceed as i got an errer i.e. Unable to find entry point for that menthod.
|
|
|
|
|
there is a property called allow paging =true, in vb.net datagidview.
can i directly allow the paging =ture in c# datagidview.
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
what application did u build?
a Web Apps or a Win App
Regards,
Tomi
|
|
|
|
|
window app
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
Since you said below that it is a Windows application, I don't know how you found an AllowPaging property in VB.NET. Properties are not artefacts of the language you are using, but of a class. A control, like the DataGridView, has the same properties whatever language it is used in, and the Windows forms DataGrid view doesn't have an AllowPaging property at all.
"Once in Africa I lost the corkscrew and we were forced to live off food and water for weeks." - Ernest Hemingway
My New Blog
|
|
|
|
|
Basically I want to use COM Interop facility and expose some functionality from my .Net application (made in 2.0 n above)to COM Client (which can be any application in VB 6.0 or c++). My requirement is when COM client makes a call to my .net component, my .Net application should start in the background and after the work is over .net application should stop automatically. So to fulfill this I will have to make COM+ Servers. Now as my component is in exe form, I understand that I will have to create a Out proc server. But in .net I don't find any easy way to register my application as out proc.
I searched the web and also code project site but not to much help. On code project site I found some useful information but the way of implementation shown is bit too difficult. (Pls visit : http://www.codeproject.com/useritems/BuildCOMServersInDotNet.asp[^])
Is there any easy way to fulfil my requirement in easier way? Pls advice.
regards,
Krunal
|
|
|
|
|
am I not clear with my question or its tough nut to crack for fellow mebers. If you want further clarification on question pls get back to me. I'm eagerly waiting for some response...
|
|
|
|
|
It's not too hard to crack. It's just too easy to Google[^].
|
|
|
|
|
[CODE]
private void CreateMaze(int h, int w)
{
int r = h * w;
Room[] rooms = new Room[r];
Random rm = new Random();
int newrm = rm.Next(0, r);
int nrmcntr = newrm;
do
{
rooms[newrm].rWall = "|";
if (newrm == rooms.Length() -1)
{
newrm = 0;
}
newrm += 1;
}
while (newrm != nrmcntr);
[/CODE]
At the line:
if (newrm == rooms.Length() -1)
I am trying to compare an integer to the last index of an array of room objects.
I get the error:
Method name expected
at that line but have no clue.
Thank you in advance for any explanations.
|
|
|
|
|
Length is a Property for arrays not a Method
use rooms.Length-1 instead of rooms.Length()-1
good luck
|
|
|
|
|
i want to pass for example an employeeid which exist in the first form and on clicking the button the second form appear containing all data (firstname,lastname,hiredate,....)for this employeeid
dina
|
|
|
|
|
Pass it in the constructor, or via public properties. If form2 is not a child of form1, pass it using a delegate.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I Have a function that takes arguments and process and return a dataset (the scenario is working fine), Now i need to put my function in thread but unable to find any way to pass arguments to thread and take return argument from thread.
Totally clueless to threads,
Please Help!!!!
Thank you!
M. Nauman Yousuf
"Mess with the Best, Die like the rest"
|
|
|
|
|
Hi,
have a look at the BackgroundWorker class, that is intended for such situations.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/AllLanguages/General
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|