|
I know all the above steps..But i want to know how to attach the saved image while postiing in this forum.. I didnt see any option while posting this message which says "attach ur files" .. I tried copying the image and paste it inline but tht is also not working..
Thanks
Sudhakar
|
|
|
|
|
I have a custom class called Invoice, which has a property Customer. This property Contains a reference to a customer class.
I want to bind a combobox to a the list of customers and bind the selected value to my Customer property. How can I do this?
"Every rule in a world of bits and bytes can be bend or eventually be broken"
|
|
|
|
|
Bind the ComboBox to your Customers property, and set the DisplayMember and ValueMember to the properties for a Customer class that you want to bind:
comboBox1.DisplayMember = "Name";
comboBox1.ValueMember = "ID";
comboBox1.DataSource = someObject.Customers; See the property documentation for the ListControl.DataSource property for more information and an example (ComboBox extends ListControl ).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi All
I am calling the function from DLL using InteropServices. But when i called the function that accept the string as parameter NullReference exception is thrown.
Actual function signature:
int GetName(int pModel, int iVar, char *pszVarname);
Function Signature for C#:
[DllImport("C:\\MyFunctions.dll")]
public static extern int GetName(int nProb, int nIndex, ref string sVarName);
Fuction Call:
string sVarName;
int nErrCode, i;
i = 14;
sVarName = "x123456";
nErrCode = GetName(nProb,i, ref sVarName); //Getting NullReferenceException
Thanks in advance
qur
|
|
|
|
|
Don't ref the string. A char* is a string . The signature in C# should be (and loose the path - put the DLL in a directory in your PATH environment variable, or the current application directory):
[DllImport("MyFunctions.dll", CharSet=CharSet.Ansi)]
public static extern int GetName(int nProb, int nIndex, string sVarName); Also notice the CharSet field in the DllImportAttribute . .NET deals with Unicode strings. If you don't specify a CharSet , CharSet.Ansi is used by default for C# and VB.NET, but it's still a good idea to specify it for readability.
Also notice there's no out or ref keyword for the sVarName parameter (which, by the way, can be called anything you want). A String (C# alias string ) is already a reference type.
Also, if you want your code to be portable, those int parameters and return should actually be IntPtr . An int in C/C++ is a processor-dependent bit width (i.e., 32 bits on a 32-bit CPU, 64 bits on a 64-bit CPU). int in .NET (an Int32 , actually) is always 32 bits. When .NET 2.0 is released and if your code runs on a 64-bit platform (and your native DLL is recompiled for a 64-bit platform), your call will fail.
Finally, never make P/Invoke'd methods public (unless the class that declares them is private or internal). Native function calls are unmanaged, so the CLR can't determine if someone would exploit your code. Depending on your native implementation, someone could easily perform a buffer overrun using the string variable and the CLR couldn't prevent it because it's unmanaged. P/Invoke'd methods are typically wrapped in a class that encapsulates the functionality that you're trying to use in a native DLL. Many classes throughout the .NET Framework Class Library (FCL) - such as every Control in Windows Forms - does this.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hi all...
i am hoping this is a simple request, but, i have developed a Java web service running under LINUX, and from what i can see, the service is coming up quite nicely... but...
i am using a C# app to call the web service, and i keep on getting a java.rmi.RemoteException coming up during debug, but no info on what that exception has in it...
is there any way of getting the exception message so i can handle it?
cheers and thanks in advance...
nik
Nik Vogiatzis
PhD Candidate: University of South Australia
+++++++++++++++++++++++++++
Developing new generation Traffic Micro-simulation Tools for Traffic Engineers
|
|
|
|
|
Where is the exception occuring? On the client or server? Unless the generated web service proxy also contains a definition of the java.rmi.RemoteException , this information wouldn't be available to the client because that exception doesn't exist in the .NET FCL. The exception on the client should've been wrapped in a generic Exception (typically). Depending on mappings, the Message property may or may not have a message associated with it (other than any generic, default message that might be configured).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hi heath...
thanks for the quick response...
long story short, the error is occuring at the server end (on a LINUX server running AXIS)...
i would suggest that the web service proxy doesn't have the definition as the Java2WSDL and WSDL2Java are, from my understanding, not designed with .NET clients in mind...
i am wondering 'how' i am meant to go about wrapping the exception, or if there is a better way you could suggest...
thanks again, i appreciate the help...
cheers
nik
Nik Vogiatzis
PhD Candidate: University of South Australia
+++++++++++++++++++++++++++
Developing new generation Traffic Micro-simulation Tools for Traffic Engineers
|
|
|
|
|
You don't wrap it. If an exception occurs, the client should see it, even if it's a generic error wrapped in an Exception class.
If you're getting an exception on the server, you'll simply need to debug what's going on.
There are problems when mixing Java and .NET for web services, typically when you use types that either aren't correctly defined in the WSDL. The class generator (same as wsdl.exe on the command-line) might not be generating the right classes.
Without specifics, it's hard to say.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hmm... no probs...
please tell what specifics you need that will help you help me...
as for the class itself, the interface is from memory (as the code is at work)...
<br />
public interface SysReport extends (...)<br />
{<br />
java.lang.String[] runReport(java.lang.String var1,..., java.lang.String[] err);<br />
}<br />
there are whole lot of variables in the middle, which i just can't remember right now, but i will send them once i get to work...
cheers and thanks for your help so far...
nik
Nik Vogiatzis
PhD Candidate: University of South Australia
+++++++++++++++++++++++++++
Developing new generation Traffic Micro-simulation Tools for Traffic Engineers
|
|
|
|
|
Hi,
I was wondering if anyone has seen an example of how one can send an HTTPWebRequest, passing in a schema to define what information your sending and have an app, aspx? file retrieve process the request and send a response
Kind Regards,
Rik
|
|
|
|
|
You just need to upload the file via POST. If you look at the HttpWebRequest.GetRequestStream method documentation in the .NET Framework SDK, you'll find a nice example.
Note that this uses POST, though, not GET (which uses the query string). Sending a schema via GET is riddled with problems, one of which is size restrictions. A GET query string can only be so long (128 bytes, IIRC), and schemas can easily break that barrier.
In ASP.NET, there is an easy way to get files that are uploaded. See the HttpRequest.Files property documentation in the SDK. Use Page.Request to get the HttpRequest , then enumerate the Files property. Do what you need with the schema then send your response using the Page.Response property (an HttpResponse ).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi Guys,
I'm trying to compile my C# class into DLL but unfortunately, the csc command is missing. "csc is not recognized as internal/external command." Is there any other way to compile it. I developed the class using VS .net under c#. Please if you could help me by directing me to sites that has the solution...
thanks in advance i'm a little bit in a hurry becuase of the deadline.
regards
/dabuskol
|
|
|
|
|
Why not just go and change the properties of the solution. Change the output type to class library in the output type of the general tab in common properties. Build your solution, go to your debug folder and collect your dll from there.
Tarakeshwar
CCIE Q(Routing and Switching), MCSE Security
|
|
|
|
|
Thank you very much.... I didn't know that. I will to incorporate my dll to my new solution.
regards
/dabuskol
|
|
|
|
|
If you're not using VS.NET, you either need to type the fully qualified path to csc.exe or add the directory it's in to your PATH environment variable (recommended so you don't need to type the path all the time). For .NET 1.0 and 1.1, the paths are listed below:- .NET 1.0: %WINDIR%\Microsoft.NET\Framework\v1.0.3705
- .NET 1.1: %WINDIR%\Microsoft.NET\Framework\v1.1.4322
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Health,
Thank you. I will try this when I do the recompilation. Anyhow, I tried to incorporate it in my new porject and it's working perfectly. I'm happy to say that this is my first class that is 100% my own ops in C#. he!he!he! "reusable codes"....
Regards
/dabuskol
PS: I'm new to c#
|
|
|
|
|
Hi,
1. I Designed MyEditor inherited UITypeEditor
public class MyEditor: System.Drawing.Design.UITypeEditor
{
private IWindowsFormsEditorService edSvc = null;
public override object EditValue(ITypeDescriptorContext context,
IServiceProvider provider, object value)
{
if (context != null&& context.Instance != null
&& provider != null)
{
edSvc = (IWindowsFormsEditorService)provider.GetService(typeof
(IWindowsFormsEditorService));
if (edSvc != null)
{
// Form Create
FormMyEditor dlg = new FormMyEditor((string) value);
if( edSvc.ShowDialog(dlg) == DialogResult.OK)
{
context.OnComponentChanged();
}
}
}
return value;
}
public override UITypeEditorEditStyle GetEditStyle
(ITypeDescriptorContext context)
{
if (context != null && context.Instance != null)
{
return UITypeEditorEditStyle.Modal;
}
return base.GetEditStyle(context);
}
}
2. Mapped MyEditor at Property
public class UserInfo
{
private string userName = string.Empty;
[Category("UserInfo"),DesignOnly(false)]
[Editor(typeof(MyEditor), typeof(UITypeEditor))]
public string UserName
{
get {return userName;}
set { userName = value; }
}
public UserInfo(){}
}
3.At RunTime, generally, MyEditor worked well at form application.
but, MyEditor did not work in other form application.
.NET called default string editor.
why .NET didn't call MyEditor in some case ?
thanks to regards!
|
|
|
|
|
How is your editor being invoked? Design-time components are required in order to work with the ComponentModel features of .NET. This doesn't mean they're limited to use at design-time (we use them in our runtime application), but the write objects must exist.
For example, the PropertyGrid provides design-time facilities even at runtime, using the ComponentModel. If you are trying to invoke your editor programmatically, you must also provide implementations of the ITypeDescriptorContext , IServiceProvider (that can return an instance of what services you need, like the IWindowsFormsEditorService ), etc.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I have code that subtracts two variables (type: double). The problem happends when both variables have the same value (should get 0)...
change = grandTotal - totalPayments;
but result is: 1.4210854715202E-14
(found that out with the MessageBox)
It's mucking up my if statement:
if (change > 0)
thanks,
Ron
|
|
|
|
|
doubles are not accurate they will often contain rounding errors.
You should used double.Epsilon to deal with it.
For example code to test equality should do something like this:
if (Math.Abs(testValueA - testValueB) <= double.Epsilon)
{
}
So your if statement could be something like:
if (change > double.Epsilon)
{
}
Does this help?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
Thanks Colin,
I didn't realize that double would be so buggy.
Ron
|
|
|
|
|
myNameIsRon wrote:
I didn't realize that double would be so buggy
Its not buggy - That how double works. As the precision of floating point operations on processors increases the problem will decrease, but it will never go away completely.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
Are you working with money (I can guess it from the variables)? So why use Double if you could use Decimal type for money.
Just my 1 cent
Regards,
Serge (Logic Software, Easy Projects .NET site)
|
|
|
|
|
Hi Serge,
Thanks, I thought that double would be sufficient...
but I guess not! Using decimal fixes the problem )
Ron
|
|
|
|