|
Try creating something and then post any issues you run into.
|
|
|
|
|
There is plenty of self-learning stuff out there:
Connect C# to MySQL[^]
ZetCode.com MySQL C# Tutorial[^]
People becoming wiser in order to notice the stupid things they did back in the young days. This doesn't mean that they really stop doing those things. Wise people still do stupid things, only on purpose.
|
|
|
|
|
Hello,
First of all sorry for my english.
My Case:
I have ann application to querry Active directory and some log files and show the output in a nice GUI.
Thiss app help many of my collegas to get information about users.
I would like to be able to notify my stuff about one of the user:
i can't understand how i can temporary save all output of my querry on the server and then send a notification to a concerned collega.
Hi might be able to retrive the result of the querry.
-----
I have already a running server with Objects necessary for my application on tcp channel with singlecall.
Thanks in advance for help
|
|
|
|
|
Don't post this in multiple places - it duplicates work and annoys people.
You have this posted in QA, so leave it there and don't add it elsewhere...
The only instant messaging I do involves my middle finger.
English doesn't borrow from other languages.
English follows other languages down dark alleys, knocks them over and goes through their pockets for loose grammar.
|
|
|
|
|
This is my XML structure after serializing
="1.0"
<ArrayOfTaskModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<TaskModel>
<TaskID>Task ID 1</TaskID>
<TaskDecs>Task Desc 1</TaskDecs>
<TaskPerson>Task Person 1</TaskPerson>
<TaskLong>Task Long 1</TaskLong>
<TaskLat>Task lat 1</TaskLat>
<TaskQuestions>
<TaskQuestion>
<TaskQuestionId>1</TaskQuestionId>
<TaskQuestionType>Task Type 1</TaskQuestionType>
<TaskQuestionTitle>Task Title 1</TaskQuestionTitle>
<TaskQuestionDesc>Task Desc 1</TaskQuestionDesc>
<TaskQuestionAnswers>
<string>test</string>
<string>test2</string>
</TaskQuestionAnswers>
<Answers>
<string>test</string>
<string>test2</string>
</Answers>
</TaskQuestion>
</TaskQuestions>
</TaskModel>
</ArrayOfTaskModel>
Now I want to add all data from this xml file into my datagridview. I tried to use this code
XmlSerializer xmlser = new XmlSerializer(typeof(List<TaskModel>));
StreamReader srdr = new StreamReader(@"D:\myfile.xml");
List<TaskModel> p = (List<TaskModel>)xmlser.Deserialize(srdr);
srdr.Close();
dataGridView1.DataSource = p;
With my TaskModel class is
public class TaskModel
{
public string TaskID { get; set; }
public string TaskTitle { get; set; }
public string TaskDecs { get; set; }
public string TaskPerson { get; set; }
public string TaskLong { get; set; }
public string TaskLat { get; set; }
public string TaskTime { get; set; }
public List<TaskQuestion> TaskQuestions { get; set; }
}
And TaskQuestion.cs is
public class TaskQuestion
{
public string TaskQuestionId { get; set; }
public string TaskQuestionType { get; set; }
public string TaskQuestionTitle { get; set; }
public string TaskQuestionDesc { get; set; }
public List<string> TaskQuestionAnswers { get; set; }
public List<string> Answers { get; set; }
}
If I deserialize with the above code, I just get some element of TaskModel, except TaskQuestions because it
TaskID | TaskTitle | Task Desc | TaskQuestionID | TaskQuestionType | TaskQuestionAnswers Please help me.
|
|
|
|
|
don't use this code as follow:
ManagementBaseObject inPar = null;
ManagementBaseObject outPar = null;
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc = mc.GetInstances();
<pre lang="cs">inPar = mo.GetMethodParameters("EnableStatic");
inPar["IPAddress"] = new string[] { "192.168.16.248", "192.168.16.249" };
inPar["SubnetMask"] = new string[] { "255.255.255.0", "255.255.255.0" };
outPar = mo.InvokeMethod("EnableStatic", inPar, null);
If the WMI service is not open, then you can not use it
Is there any other way????
|
|
|
|
|
|
+1
|
|
|
|
|
|
Hi all,
I want to develop an application which reads DTD file and provides form to user for requested data and generate xml out of it. Can anybody help with how to read DTD file in c#?
Thanks
|
|
|
|
|
A DTD files[^] is just text, so you read it with a TextReader [^]. The link above will help you to interpret the content.
Veni, vidi, abiit domum
|
|
|
|
|
Hello,
I hope somebody can help me and I hope I put my questions into the right forum !!
If not pls let me know !!
I received a c++ dll with a function inside:
int FunctionCall(int* Size, unsigned char Data[], int time)
I used the DLLImport:
[DllImport("Function.dll", CallingConvention = CallingConvention.Cdecl)]
extern static int FunctionCall(IntPtr Size, byte[] data, int timeout);
But when I debug I always get an out of range error !!
What did I wrong ??
Thank you very much for your help !!
|
|
|
|
|
You need to show the code that gives the error, the exact error code or message, and the values of all the variables that are used in the call to the C++ function.
Veni, vidi, abiit domum
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.InteropServices;
using System.Data;
namespace ConsoleApplication1
{
class Program
{
[DllImport("Function.dll", CallingConvention = CallingConvention.Cdecl)]
extern static int Fct1();
[DllImport("Function.dll", CallingConvention = CallingConvention.Cdecl)]
extern static int Fct2();
[DllImport("Function.dll", CallingConvention = CallingConvention.Cdecl)]
extern static int Fct3(IntPtr Size, byte[] data, int timeout);
[DllImport("Function.dll", CallingConvention = CallingConvention.Cdecl)]
extern static int Fct4(int size, byte[] data);
static void Main(string[] args)
{
byte[] data = new byte[5] {0x01,0x02,0x03,0x04,0x05};
int result = Fct1();
Console.WriteLine(result);
result = Fct2((IntPtr)2, data, 3);
Console.WriteLine(result);
result = Fct3(3, data);
Console.WriteLine(result);
result = Fct4();
Console.WriteLine(result);
}
}
}
ErrorMessage:
AccessViolation at Fct2
|
|
|
|
|
|
Sorry to bother you
I´m very glad about your help !!
And I have to excuse me but I don´t have much experience in C# coding..
I will give you more details what I want to do:
I have a windows programm from and I have to make a communication to this programm.
The supplier of the other programm provided me a dll with different functions inside.
Now from my understanding the easiest way to setup the communication is to use this dll.
So I only wanted to make a short trial if I can call this functions and if the communication can be
established !
Fct1, Fct3 and Fct4 are returning a value that shows a good result.
The problem is Fct2 where I have to deal with pointer (
Thanks again !!
|
|
|
|
|
Even if your code was good, you cannot pass a pointer to a constant value!
The point of passing a pointer is so that the method you call can modify the value in your program. If you could pass a pointer to "the number two" what do you expect to happen when the function tries to change it?
As I said, you almost certainly want to pass a ref int instead of an IntPtr as the former actually passes a pointer rather than a value in a "pointer package"! (And C# won't let you call your method as Fct2( ref 2, data) for precisely the reasons above)
The only instant messaging I do involves my middle finger.
English doesn't borrow from other languages.
English follows other languages down dark alleys, knocks them over and goes through their pockets for loose grammar.
|
|
|
|
|
You really need to study that P/Invoke tutorial I gave you the link for. You are not going to learn this just by asking a question here, as there are quite a few rules and restrictions that you need to understand.
Veni, vidi, abiit domum
|
|
|
|
|
This call is wrong:
result = Fct2((IntPtr)2, data, 3);
The first parameter should be a pointer to the address of memory which contains the size of the "data" array. Casting a literal "2" to IntPtr is telling the library that the length of the array is in the block of memory with the address 2. Try changing the function definition like this:
[DllImport("Function.dll", CallingConvention = CallingConvention.Cdecl)]
extern static int Fct3(ref int Size, byte[] data, int timeout);
And call it like this:
int dtLength = data.Length;
result = Fct2(ref dtLength, data, 3);
See you
|
|
|
|
|
Thank you very much !! I got it )
|
|
|
|
|
Show us the code where call that function, the error is likely there in the data.
|
|
|
|
|
As Richard says, we need to see the code you use to all it to be sure, but I think you need to replace the IntPtr with a ref int unless you are already dealing with unsafe code.
[DllImport("Function.dll", CallingConvention = CallingConvention.Cdecl)]
extern static int FunctionCall(ref int Size, byte[] data, int timeout);
The only instant messaging I do involves my middle finger.
English doesn't borrow from other languages.
English follows other languages down dark alleys, knocks them over and goes through their pockets for loose grammar.
|
|
|
|
|
I think the problem is that byte[] in C# is a managed array, which is not equivalent to the address of the first member as it is in unmanaged C++. You will probably have to use a pointer type for this parameter as well. You will need an unsafe block and should probably also use the fixed keyword to prevent the Garbage Collector from moving the content of the array while the C++ function is using it.
The good thing about pessimism is, that you are always either right or pleasently surprised.
|
|
|
|
|
how to have treeview in asp:menu ?
Thanks in advanced!
|
|
|
|
|
The same like any other control. Did you try anything, or are you just looking for someone to make your treeview?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|