|
Hello Team,
I have a jar file which has some classes.I want to access those class files from .net environment.I mean i want to pass some parameters from .net environment to class files and process the parameters in class files and send response back to .net environment.
please help me
|
|
|
|
|
|
1. Write a jave app that uses the classes and models the functionality you need.
2. Write a communications API on that using either stdio, files or sockets.
3. Use Process (or whatever it is called in .Net) to run and manage the java exe
4. Use the communications API, from 2, in your net code to talk to the executable.
Advantage to this over in process functionality is that it is easier to debug.
|
|
|
|
|
There's a very handy library, called IKVM[^], that you should really look into. It makes working with Java and .NET an absolute cinch.
|
|
|
|
|
I am new in developing apps(C#.net),my problem is I want to print a panel using enter key and cancel using escape key when mouse pointer is inside the panel area
|
|
|
|
|
Add a key event handler to your panel, which will call the appropriate method according to which key is pressed. See the tutorials here[^] on Delegates and Events.
Use the best guess
|
|
|
|
|
hey all, Sorry its me again. This time I have a question that I think is fairly general. I am using code that is almost exactly the same over and over again within a controller.
My question was, is there a way to store this code somewhere within the project? to repeat it in the place that i need in code
in c# windows application??
e.g:
like include PHP
all that i need is to repeat specific code in my function but in different locations
any ideas???
|
|
|
|
|
Such common methods can be added to "helper" classes that you can reuse across the application.
You can think about making this class a singleton.
|
|
|
|
|
thanks for your reply
but do u have tutorial to make it coz i am a beginner in c#
|
|
|
|
|
A common way to do this is to create a class library that you use to hold common methods. Suppose, for instance, that you have a piece of code to check whether or not an integer is between two values, and you use this in many projects, you could add the code to a static class like this:
public namespace RangeExtensions
{
public static class Range
{
public static bool IsInRange(this int value, int startRange, int endRange)
{
return value >= startRange && value <= endRange;
}
}
} This is known as an extension method, and as long as you add the DLL that contains this code and add the namespace declaration as a using statement to any class that uses it, you can do things like this:
private void GetValueAndValidateIt()
{
int value = GetValueFromSomewhere();
if (value.IsInRange(0, 10))
Console.WriteLine("The value is between 0 and 10");
else
Console.WriteLine("Drat it you fool, you just blew up the planet");
} Now, if you drop the this statement from the Extension method, you would call it like this:
private void GetValueAndValidateIt()
{
int value = GetValueFromSomewhere();
if (Range.IsInRange(value, 0, 10))
Console.WriteLine("The value is between 0 and 10");
else
Console.WriteLine("Drat it you fool, you just blew up the planet");
} So, what's the difference? Well, the this keyword at the start of a method declaration parameter list indicates to the compiler that this is an extension method; that is, a method that allows you to extend the functionality of an existing type.
|
|
|
|
|
If the code is repeated in the same controller you should extract out to a single method. From your description it sounds like you have the same block of code in several controllers, in which case you extract out the method into a common base controller and inherit from it. e.g.
public abstract class MyBaseController
{
protected void CommonCodeMethod()
{
}
}
public class MyController1 : MyBaseController
{
public void Foo()
{
CommonCodeMethod()
}
}
public class MyController2 : MyBaseController
{
public void Foo()
{
CommonCodeMethod()
}
}
You should put the base in it's own file (as your controllers probably are). You might not need the abstract on the class, and you might want to make CommonMethod public or internal .
If the function is used outside of controllers, then the base class isn't suitable: create a separate class that contains the common method, try to give the class used a descriptive name (for example, if the common methods all create ViewModel called FooViewModel , consider FooViewModelCreator as the class name and Create as the methodname). If you have several such methods, try to keep ones that fit naturally together in the same class, so the class is only really responsible for one category of thing and you have [potentially] several classes.
[Edit]
Countered Univotes. Note sure why your question was downvoted, seemed to me to be a sensible newbie question - perhaps the downvoter could elucidate.
“Education is not the piling on of learning, information, data, facts, skills, or abilities - that's training or instruction - but is rather making visible what is hidden as a seed” “One of the greatest problems of our time is that many are schooled but few are educated”
Sir Thomas More (1478 – 1535)
modified 18-Jun-13 8:44am.
|
|
|
|
|
Just added my 5 to his vote.
|
|
|
|
|
I am trying to reference 2 identical assemblies with only their filename and version to be different. I need this in order to support several versions for backward compatibility.
I've created an alias name for one of them and the other stayed "global". Also added the "extern alias" declaration at the start of the source code.
I'm getting compiler error (my real module name was switched with [module name] here):
"An assembly with the same simple name '[module name], Version=1.0.0.0, Culture=neutral, PublicKeyToken=null has already been imported. Try removing one of the references or sign them to enable side-by-side."
One of these two assemblies does have a version 1.0.0.0, but the other has 1.5.0.0 and I can see that when I highlight them in the solution explorer in the properties window.
The assemblies are not signed, and I do not currently wish to make them as such. Why is this error? The versions are clearly different… is there a way to solve this?
i'm using VS2012.
|
|
|
|
|
Using different AppDomains would solve it.
|
|
|
|
|
It won't solve it since i need to load both assemblies in the same domain.
|
|
|
|
|
Try this[^]
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
i already found this before, but it does not offer a working solution:
i cannot change the assembly info since it is a compiled module and as i said - the assemblies are not signed, but they have a different version.
Any other way to make it work?
|
|
|
|
|
impeham wrote: Any other way to make it work? Remove the reference and load the assembly dynamic.
If you want to use the simple names, you'd have to abide by it's rules.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Pretty sure that your requirements, per your posts, means there is no solution.
So either relax your requirements or don't do it.
|
|
|
|
|
In an app where you think about "backward compatibility" and other things you should really use strong names for the assemblies - So I'd question why you are not using strong-names (signing). I can't think about a good reason for not doing it (and solving your problem) other than "too lazy to manage the certifcate"... Even if you don't worry about installing your assembly in the GAC or your manufacturer authenticity, there a good reasons for signing - you just found one!
|
|
|
|
|
Signing the assemblies would probably be the best solution - i agree.
At the moment it is not feasible since there are clients with this module in the field already that cannot be upgraded with new signed assemblies.
I am using a workaround for this in the meantime - I am changing the assembly name from the project properties (changing the version and the title in assembly information did not work). I still have a few tests to do before I'll know it is working for sure (without the need to upgrade any client modules).
|
|
|
|
|
I have created a website using C#.I need to implement barcode generator to certain pages.
I have tried with the below link.
http://www.codeproject.com/Articles/3888/C-Barcode-Generator-WebService
I am not familiar with the .resx and .asmx files.
Could any one help me explaining this..
Thanks in advance..
|
|
|
|
|
0. You have posted this question in Q&A - Do not repost here
1. There is a forum at the bottom of the article - the author will be better placed to help you.
2. "generate barcodes in c#" produces ~1,900,000 results in Google, please try those first
It is unlikely you'll want to use a web service if you just want barcodes. You can download barcode fonts[^] and use those directly, but you'll need to check compatibility.
“Education is not the piling on of learning, information, data, facts, skills, or abilities - that's training or instruction - but is rather making visible what is hidden as a seed” “One of the greatest problems of our time is that many are schooled but few are educated”
Sir Thomas More (1478 – 1535)
|
|
|
|
|
hello guys, I need help, I'll explain the problem ...
I am making a wpf project that pressing a buttom let me see the video of the IP camera, only to see that the string directly to the video does not work, so I use the string of the image that is updated every time, to do this use the thread, and to avoid exceptions, use the delegates, only that at some point I will generate this error:
An unhandled exception of type 'System.StackOverflowException' in WindowsBase.dll
The point at which I generate error is as follows:
Del Ert = new Del(setImage);
images.Dispatcher.Invoke (ert, new object [] {images, url});
the type
Del is my delegate:
public delegate void Del (Image images, string url);
I hope you can help me, if you need some additional information I can post it
|
|
|
|
|
The most common way for this to happen is for an infinite recursion or loop to happen, e.g. a method calling itself (or calling itself via other method(s)) in such a way that the loop never ends. There is a stack object used by the .net framework when it executes your code (called the call execution stack), this has a finite size. Normally you enter a method (the call is pushed on the stack) and when the method exits the method is removed (popped off) from the stack. When infinite looping happens the method (or methods if a calls b calls c calls a etc) is repeatedly popped onto the stack filling it, then it overflows. As the stack is large this normally takes a few seconds though it can take even longer depending on your intervening code.
One problem with this is that the stack overflow exception doesn't necessarily happen where the actual problem is, so you might not have included the recursive code needed so we can help you in your problem.
I suggest two options:
1) Run the code until the error occurs, then open the stack trace window[^]. You'll see the calls made by your code and by reading through this you'll see the loop and hopefully where you need to break out of it.
2) Put a breakpoint on the code where you are getting the failure, then step through. At some point you'll loop round (hopefully quickly!) again you'll need to decide where you want to break out.
I'd try these two first, the first option is quicker though if you can't spot your problem then the second option will be clearer. There is a possibility that images.Dispatcher.Invoke (ert, new object [] {images, url}); is causing the loop, if ert is either directly or indirectly recursive. The other thing that might be the case (though unlikely) is that you have an non call-stack which is filling, but even this is likely to be filled by an infinite loop.
[Edit]
Me use INglish good and tipe weLL
“Education is not the piling on of learning, information, data, facts, skills, or abilities - that's training or instruction - but is rather making visible what is hidden as a seed” “One of the greatest problems of our time is that many are schooled but few are educated”
Sir Thomas More (1478 – 1535)
|
|
|
|