|
The C++ DirectShow Library's IVideoWindow and C#'s DirectShowLib::IVideoWindow^ are not the same interface (at least externally). SetPreview is looking for C#'s IVideoWindow; thus, you may need to use COM callable wrapper (CCW) of your DirectShowLib::IVideoWindow^.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
modified on Wednesday, October 1, 2008 2:05 PM
|
|
|
|
|
George L. Jackson wrote: you may need to use COM callable wrapper (CCW) of your DirectShowLib::IVideoWindow^.
What is that?
|
|
|
|
|
I have a question regarding STA/MTA in .net
I need to build a COM object in .net whose threading model is required to be STA only (not Both,..) because it is not safe to be used in MTA apartment.
How to do it?
Thank you very much!
|
|
|
|
|
I have some code which use Debug::Print() to output some debug strings. I notice it also prints in the release build version. IIRC, this is not the case in C#.
Folks, any explanation for this anormaly?
Thank you very much!
Edited: I am using Visual Studio 2005. Looks like I got to use a #ifdef guard to prevent the Debug::Print from printing in the release build.
modified on Sunday, September 28, 2008 9:57 PM
|
|
|
|
|
Just for the record, the MSDN Library says (http://msdn.microsoft.com/en-us/library/system.diagnostics.debug.aspx[^]):
"ConditionalAttribute is not supported by the C++ compiler. To provide equivalent functionality, you must enclose calls to the methods of Debug in an #if defined(DEBUG) ... #endif block, and add the /DDEBUG option to the compiler command line or add #define DEBUG to the file."
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi,
I have one JNI shared libray which depends on a CPP library.
In my module loading CPP shared library first and loading JNI library, eventhough the dependant library is loaded JNI library tries to load CPP shared library.
Please let me know how to avoid loading an already loaded shared library ....
Thanks,
Yashu
|
|
|
|
|
Yashusid wrote: I have one JNI shared libray
As in Java Native Interface? If so this is not even close to being the correct forum. If not then what is it? Supply a link.
In terms of loading modules into Windows Processes put all the modules in a single location. The loader will see that it is already loaded and not load it again.
link[^]
Note Use extreme care when using this value. If LoadLibrary or LoadLibraryEx is called for the same DLL after the DLL is loaded, then the DLL references will not have been resolved. This is because the second call to LoadLibrary or LoadLibraryEx simply returns a handle to the already loaded DLL. In this case, the process is likely to terminate abnormally.
led mike
|
|
|
|
|
I have some code that fails when I do this:
Char mgData[] = new Char[numBytes];
Marshal::Copy(data, mgData, 0, numBytes);
...but does not fail when I do this:
Byte mgData[] = new Byte[numBytes];
Marshal::Copy(data, mgData, 0, numBytes);
data is of type char*, and contains binary data in the form of individual bytes (not represented as text at all). numBytes is the length of char*, when it was created with...
char* data = new char[numBytes]
The specific error that I'm getting is in Marshal::Copy, and the debugger points me to memcpy.asm. This leads me to believe that it's something unconventional, or that I'm simply not handling my unmanaged to managed conversions properly. There's a bit of background though... the reason why I'm trying to convert from unmanaged char* to managed Byte[] is because a BinaryWriter object won't properly write binary data when it's in the form of char*. If I were to call...
BinaryWriter.Write(char*) , it would simply write until it thinks that it's at the end of a text string (likely a null-terminated character, or something along those lines). Furthermore, I'm not sure if using the Byte instead of the Char is incorrect, since Byte is an unsigned type, and Char (I think) is signed, which matches char* (also signed).
Any suggestions?
|
|
|
|
|
FYI
System::Char is an Unicode character that corresponds to native C++'s wchar_t , and System::Byte corresponds to native C++'s char .
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
I guess I was doing the right thing, then. I just thought there would be a signed/unsigned mismatch.
Thanks.
|
|
|
|
|
Cyrilix wrote: I just thought there would be a signed/unsigned mismatch.
Nah. Marshal.Copy() has no idea what your passed IntPtr points to.
You just have to make sure there's enough room there for whatever gets copied
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
(Sorry for my bad English in advance!)
I would like to know what do game developers think about C++/CLI and whether it's practical to use C++/CLI in game development. Or, is the performance that bad(like with C#) that native C++ is still dominating? If some game developers are around here, that would be cool!
|
|
|
|
|
I am not a game developer. IMHO, pure C++/CLI would have similar issues C# has. You can boost the performance of C++/CLI with native C++; however, it will never equal the performance of native C++ in many circumstances.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
HI I want an array to be filled with spaces when declaring it?
How would you do it?
array<wchar_t>^ indicators = gcnew array<wchar_t>(sentence->Length){L' '};
Is the the correct form?
Well but this only initializes the first element to space and the rest to null?
|
|
|
|
|
I don't believe there is a simple way to initialize each item in a array<T> to a custom default value. However, if you are desperate, you could use the following:
#include <cliext/vector>
using namespace System;
using namespace cliext;
int main(array<System::String ^> ^args)
{
array<wchar_t>^ vals = (gcnew vector<wchar_t>(10, L'a'))->to_array();
for each(wchar_t val in vals)
Console::WriteLine(val);
return 0;
}
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi, I am new here, and I have a little question...
I am making a program, that does several things, but the pin point is when I create a shortcut. For easy coding, i was "forced" to use IWshShell and so on, and add a COM reference that enables me to do so. All goes well, until I come to a little problem, wherever my program goes Interop.IWshRuntimeLibrary.dll needs to go with him. I have searched for hours to find a way to attach it to main project or exe, but it seems impossible. Can someone help me to get a way to attach it, or turn into a lib and implement, or something that allow me to create shortcuts with that ease?
Thanks for you attention.
|
|
|
|
|
class MyNative{
public:
std::string GetANativeString(){
return "Some text";
}
}; Above class returns a std::string to the caller. I need to convert the returned string to a managed string(String^ ). I have done it, but want to make sure this is the correct method. Here it goes,
MyNative native;
String^ str = gcnew String(native.GetANativeString().c_str());
Console::WriteLine(str); System::String has an overloaded constructor which accepts a char* . Is this the correct approach or should I change GetANativeString() method to return a char* ?
|
|
|
|
|
std::string requires more overhead than const char*. Other than that, I don't see any problems with using either one. Each one is appropriate.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi,
My application working fine in the dev environment.But in the testing /production environment
it is not working because that environment has only
windows server 2003
IIS
I have prepared a MSI which will automatically install .net2.0 framework
In my application I have Used some microsoft VC++ dll's also along with .net dll's.
Now Iam getting "RUNTime Error" pop-up screen message as below
" The Application has been terminated in an Unusual Way"
On googling i came to know that some dll's like msvcrt.dll of windows server 2003 has to be changed...But Iam not pretty sure about it..
In Production/test environment there is only framework installed ,but there is no visual studio installed on it.may be due that this error may occur...
So kindly post your suggestions and views to help me
|
|
|
|
|
Don't cross post. You are being rude.
led mike
|
|
|
|
|
Hiho
i have got a question concerning a application i am working on. I have got a old former native MFC Application for which i enabled the /cli switch in Visual Studio. From this application i try to call managed code. So there cannot be used System.Windows.Forms from this side of code to show a simple form. i created a new managed project with a simple class which creates a Form. I am now calling this class from the /cli MFC Application and it crashes. When i am debugging the call of the C# .Net Class, it seems to be ok but when the Form is created the debugger jumps at this point
private System.ComponentModel.IContainer components = null;
and the complete application sometimes the Studio too crahes. So is it not possible to call Forms from MFC generally or am i doing some stupid stuff ?
Greetings Torben
modified on Friday, September 19, 2008 8:17 AM
|
|
|
|
|
ToSchi98 wrote: So is it not possible to call Forms from MFC generally or am i doing some stupid stuff ?
Stupid stuff? Nah. Incorrect maybe
Not only can you call c# code from your managed C++ app, you can also host
a Windows Form user control in your MFC app.
Using a Windows Form User Control in MFC[^]
As far as your specific problem, it's impossible for me to
guess without seeing what you're doing.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hiho and thanks for the help,
Yes you are right i try to describe my problem a little bit more precisely. I think the code will make it easier to understand. I do not have to host a UserControl i think so. I only want to Show a normal Windows.Forms.Form from a C# Sharp Assembly which is referenced in the MFC CLI application to use a Microsoft ReportViewer, reporting some stuff from the Application. Is this possible in general that way or will i have to host this form too ?
Greetings Torben
//MFC Application with CLI enabled
namespace::Formstarter ^CSharpForm = gcnew namespace::Formstarter();
CSharpForm-> SomeFormMethod();
//C# Assembly
public class Formstarter
{
public Formstarter()
{
FormToStart Started = new FormToStart()
Started.show();
}
}
//Class Form
public partial class FormToStart : Form
{
public SpliceReporter()
{
InitializeComponent();
}
//Not in the partial class
public SomeFormMethod()
{
//Do something
}
}
|
|
|
|
|
Are you sure the MFC app is finding the assembly with the
form in it OK? Are they in the same folder?
I just tried this and it worked fine for me
(note I changed both project output directories
to the same folder!):
C#
1) Created a control library project with the app wizard
2) Added a form
3) Added your Formstarter class and altered it to create my form class
C++
1) Created an MFC dialog app project with the app wizard
2) Changed settings to compile /clr
3) Added a button to the dialog, along with a button clicked handler.
4) Added a reference to the C# DLL (created above) to the project
5) Added code in the button click handler (1 line) to create a Formstarter
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for the help again Mark. Yes you are right the same you did, works for me too. After you told me that it should work in general i was able to focuse an other things which cause that my app is not running.
I am developping on Win XP with VS 2008. The .Net Extension is written for the 2.0 Framework. On my developper system it works and no error is upcoming but if i put it on my target system Win2K SP4 Framework 2.0 with SP1 a microsoft error still occurs. When i put my .Net app and use ist from another .Net app instead of the MFC is works correctly so i think no Dlls are missing on the target pc. When i use a new MFC project instead of the old one it starting the .Net app everthing works fine too. If i put the call in the OnCreate Function of the main dialog of the MFC app i have to extend, it works also correct. But it does not work in my OnClickButton-method where it has to do. At the moment i am a little frustrated because i don´t know what to do anymore. I cannot debug the app because the only thing i get is this Microsoft Error. Anyone an idea perhaps ?
Greetings Torben
|
|
|
|