|
|
Manfred, please fix the broken url.
|
|
|
|
|
Thanks for pointing that out! I'm quite disturbed by the troubles I'm having with inserting links via my tablet device.
Cheers!
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
|
|
|
|
|
Hi,
through Dynamic in C# 4.0 you can achieve this, but you need to investigate it
here is the link i found to execute string in c#
hope this will resolve your problem
thanks
-amit
|
|
|
|
|
Hello ppl....
please i need a help.. i have a c# subject at my university,they give me a bonus marks to make a program (project).. i make some research in the net .. but it was difficult to choose a program to work in it.. and i want some ideas for a programs ..
tkx
|
|
|
|
|
Sounds like the perfect opportunity to make Skynet.
Somebody in an online forum wrote: INTJs never really joke. They make a point. The joke is just a gift wrapper.
|
|
|
|
|
I guess your not getting the bonus points.
No comment
|
|
|
|
|
Well, if there are no stipulations as to the nature or compexity of the project, perhaps Hello World[^]? Where do I queue to get my degree?
|
|
|
|
|
CodeProject badly needs a program to automatically reject bad subject lines. Maybe you could come up with something?
|
|
|
|
|
Luc Pattyn wrote: CodeProject badly needs a program to automatically reject bad subject lines. Could we append to that RFP: "accompanied by 'gimme' content" ?
best, Bill
When I consider the brief span of my life, swallowed up in the eternity before and after, the little space which I fill, and even can see, engulfed in the infinite immensity of spaces of which I am ignorant, and which knows me not, I am frightened, and am astonished at being here rather than there; for there is no reason why here rather than there, now rather than then. Blaise Pascal
|
|
|
|
|
When coming up with a topic like this, it generally helps if it's a subject area that interests you. That way you can keep your enthusiasm high which will help you when you run into areas where you feel stuck. Now we don't know you, so we aren't going to be much help there.
Failing that, write a program that converts gibberish text speak into real English.
|
|
|
|
|
Go here [^]
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
OP did not ask for code or a solution to homework, but was asking for ideas. Asking for ideas is not something that should be looked down upon (at least the way I see it).
Regards,
Manfred
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
|
|
|
|
|
Part of the homework assignment was to come up with the idea. If these guys aren't creative enough to even come up with their own ideas, what kind of programmer are they going to be when they graduate? How do they expect to analyze a problem, and document a solution? Development isn't just about writing code.
It doesn't have to be earth shattering, or the all-too-elusive "killer app". It's just a homework assignment. Hell, I've come up with several ideas in the last couple of years and have implemented all of them. CPAM took three weeks to develop from start to finish. Reputationator took three weeks to write (not including the article), and another two weeks for the WPF version). CamoPicker's basic implementation took all of two weeks from start to finish. I've got other examples that would be lost on you because there's no accompanying CP article.
I'm almost positive that he doesn't even have to actually finish the app. In fact, if he just showed some development cycle lifetime work and got MOST of the code implemented, he'd get full credit for it.
I stand by my "we don't do homework for people" post.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Hi,
The best way is to contribute in some opensource project. that will defiantly help you and others
thanks
-amit
|
|
|
|
|
(VS C# 2008 and C++ 2008)
I have a win32 c++ application with an entry point:
extern "C" int __declspec(dllexport) __stdcall ret_arr(float returnArray[])
{
float myArray[2];
myArray[0]=1.2;
myArray[1] = 2.4;
returnArray = myArray;
return 1;
}
I'm trying to get the array "returnArray[]" from C#:
[DllImport("MyDll.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "ret_arr")]
public static extern int ret_arr([MarshalAs(UnmanagedType.LPArray)] ref float[] retArray);
private void test()
{
float[] retArray = null;
int ans = ret_arr(ref retArray);
}
When I call my C# function - test() - in the debugger, "retArray" isn't being assigned (it remains null). Likewise, if I initialize the retArray (= new Float[2]) the array is not modified after it returns from the unmanaged dll.
I don't have any trouble retrieving a float. But working with float[] has me jammed-up. I have tried many variations including passing the argument as a pointer but I cannot, with my skillset, figure it out.
What should I try next?
|
|
|
|
|
Two comments apply here:
1.
your native code stinks. You are allocating an array on the stack, then returning its pointer. You should be aware whatever was on the stack is going to vanish as soon as the function terminates, so you should never do that, whatever the language is you are using.
2.
when you want to exchange large amounts of data between managed and unmanaged worlds, it is much much simpler to always have the memory allocated on the managed side: making the native world accept managed data is a lot easier than convincing the managed world it should accept native data. I did explain passing arrays in my little article here[^].
|
|
|
|
|
Great article (and my code does stink)
Below, for convenience, I made a copy of your code for method 1 (automatic way). I see that in the C# version an object named "pNumbers" is passed in the call rather than the "numbers" array. The VB code passes the "numbers" array itself. Is pNumbers another array or is it a pointer or is it a typo? Also, is "unsafe" required in the C# version?
C#
public int ArrayAutomatic() {
int dim=1000;
int[] numbers=new int[dim];
...
int sum=SumArray(pNumbers, dim);
return sum;
}
[DllImport("native.dll")]
unsafe public static extern int SumArray(int[] numbers, int count);
VB
Public Function ArrayAutomatic() As Integer
Dim dime As Integer = 1000
Dim numbers(dime) As Integer
...
Dim sum As Integer = SumArray(numbers, dime)
Return sum
End Function
Declare Auto Function SumArray Lib "NativeC.dll" (ByVal numbers As Integer(), ByVal count As Integer) As Integer
With your help I am able to get the array using C# by using a literal translation of your VB example:
C++
extern "C" int __declspec(dllexport) __stdcall ret_arr(float returnArray[])
{
returnArray[0] = 5;
returnArray[1] =10;
return 1;
}
C#
[DllImport("CudaFft.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "ret_arr")]
public static extern int ret_arr(float[] retArray);
private void test()
{
float[] retArray = new float[2];
int ans = ret_arr(retArray);
}
It works but it may still stink. Am I on my way?
|
|
|
|
|
You're right, there's a typo in my article, nobody ever noticed, myself including. I will fix it.
int sum=SumArray(numbers, dim); is what it should be in automatic mode.
Thanks for pointing this out.
Your code is fine. One suggestion: whenever possible, also pass the length as a separate parameter, that way your native code can be confident about how much data it can safely read and/or write (automatic mode turns the array reference into a simple pointer, so all size info isn't passed on). That is what the dim parameter is doing in my example. As always, reading memory locations you're not supposed to read may cause an exception, writing beyond the boundaries most probably will cause an exception.
|
|
|
|
|
Your article is very good. I have been researching how to pass arrays to unmanaged functions for a few days and, although there is plenty out there, your explanation was concise and complete and the implementation was simple and elegant.
I gave your website an "excellent" WOT rating. http://www.mywot.com/en/scorecard/perceler.com
|
|
|
|
|
Thanks. I'm glad you liked it.
FWIW: next year, I'll spend time to write part 2, on passing structures.
|
|
|
|
|
If you're planning to use CUDA, why not just use existing .NET bindings instead of your own? (CUDAfy.NET for example?)
|
|
|
|
|
Hi,
Although CUDA.NET has had CUFFT capabilities since at least v2.0, I was not able to fly CUDA.NET in VS 2008 Express (for CUFFT anyway) - probably just my stupidity. Learning how to communicate with unmanaged code has been a good experience. Later, I'll probably revisit an open source library approach because I'll probably get better performance. There are a couple other libraries out there (GPU.NET and MS Accelerator) but the FFT capability isn't implemented yet.
|
|
|
|
|
OK, senior moment. I'll look more closely at CUDAfy.net.
|
|
|
|
|
If I'm given a string in the format: aaaaaa.bbb.ccc.ddd....qqq. Basically the string is words seperated by a single dot. Words can be any length and the string can have any number of segments. Think C# namespace.
Now, I want to remove the last segment... so I want to take:
A.B.C.WpfApplication3.Application
and get
A.B.C.WpfApplication3
I know you just reverse find the last . and trim the string there, but I'm wondering if there are any cool tricks with split / join, linq extensions, etc?
Bored, so trying to come up with a one liner ... can't make any assumption that the last part of the string will be .Application either .
But the input IS going to be a namespace + class name. (this.GetType().ToString()).
|
|
|
|