|
Thanks for the suggestion. This week, I am going to take your suggestion of two separate projects, but I will have to have the native C++ dll call the dll with clr support. The reason is that my boost thread code needs to call .NET functionality such as ADO and WebClient.
|
|
|
|
|
Well, the point is to have the functionality of either worlds compiled separately in distinct translation units. However, the way you seem to be going is a bit harder: You will need to provide abstractions of .NET entities usable in native c++ program.
I don't know the background of what you are trying to accomplish, but I would suggest to stay "at one side of the line" (either .NET or native) as long as possible. What you have sketched above (using boost.threading with ADO and Web) smells like problems... There should be a very, very serious reason to do it that way.
|
|
|
|
|
Thanks for the input.
The code works after I separate it into two dlls. The particular function queries multiple webpages on separate threads and webclient was the only CLR functionality I utilized. I then processes the data after all of the threads come back since the processing time is small fraction of the runtime.
I also am thinking of building XLL's with functions that retrieve data from the web, require multiple database calls/queries, and do array function computations simultaneously. The .NET threads cannot be utilized in the XLL project, so I have to use Boost threads or some other thread library.
The Boost threads cannot be utilized inside the CLR project, but I am not using much more native than .NET code. So I created another dll that makes a native wrapper around the small # of functions I use with CLR.
|
|
|
|
|
I am trying to read the article 'Unraveling the Mysteries of Writing a Winsock 2 Layered Service Provider' that microsoft published in may MSDN in 1999.
The article http://www.microsoft.com/msj/0599/LayeredService/LayeredService.aspx[^] is old I admit but I could not find anything more recent that use that technique.
The goal is to write a web filter that would prevents words like ***, **** and ***** to appear in web pages.
I need to be able to rewrite the content of web pages on the fly and hopefully messengers too.
Did anyone manage to make this run in a recent Visual Studio?
I would prefer to have this written in MC++ but I fear it is beyond my C++ capabilities at this stage.
This is a compelling area of development, I am surprised I can't find an article here that would extend this sample.
I certainly hope I overlooked it.
The code is available here : http://download.microsoft.com/download/0/6/7/0678184e-905e-4783-9511-d4dca1f492b4/MSJMay99.exe[^]
|
|
|
|
|
After a lot of effort (and downloading the Windows Vista/7 SDK) I am slowly progressing on this.
|
|
|
|
|
There is a book that explains how to write one.
The book is called Network Programming for Windows - Second Edition
by Anthony Jones and Jim Ohlund
This is regarded as a classic book, so you might have to pay a high price for it.
|
|
|
|
|
Hello,
I made a DLL wrapper in managed code which is merely a wrapper function around a native C++ DLL. The DLL works perfectly except I can not see the assembly info in explorer. Using ILDASM, I can see the fields in the manifest. What could be wrong?
Thanks in advance
|
|
|
|
|
The C# and VB compilers will pull the info from assemblyinfo.cs and create the required version resource. Since C++ supports native resources it will not do this automatically. You will have to create a native version resource manually like you would with a native project. There will be some information duplication of course, but it's not a big deal I guess.
|
|
|
|
|
OK, thanks Nishant, I added a resource to VS2010 project which created the info. I needed. So in AssemblyInfo.cpp the only information that I can affect is for signing the assembly and where the key is located. Can I then remove the other fields or are they used?
|
|
|
|
|
alleyes wrote: Can I then remove the other fields or are they used?
Yeah you can remove them if you don't want to have that info in the assembly metadata (which is query-able from .NET).
|
|
|
|
|
Hello,
I am calling LoadTypeLib for loading unmanaged type libraries in C++/CLI. I need to compile some code(some code areas) as managed and some code areas as unmanaged(native) code and form a mixed mode class library as executable.
What i need to mention between the lines of code so that whatever the part i need to be compiled as managed should compiled as managed and what part I need to be unmanaged(native) should be compiled as native?
Regards
Usman
|
|
|
|
|
|
Does anyone have a sample showing how to lookup the URL to use for exchange web services via the autodiscover service.
|
|
|
|
|
Hello,
I am Loading type library from C++/CLI with following lines of code.
[DllImportAttribute("oleaut32.dll", SetLastError = true, CharSet = CharSet::Unicode, PreserveSig=false)]
static void LoadTypeLibEx( String^ strTypeLibName, RegKind regkind,[MarshalAs(UnmanagedType::Interface)] interior_ptr<Object^> typeLib );
Object^ oTypeLib;
LoadTypeLibEx( strSubject,RegKind::RegKind_None, &oTypeLib);
It again and again giving me same exception, all I have registered type library with regsrv32, placed in current directory and given full qualified path but still its giving me same exception.
Regards
Usman
-- Modified Monday, June 7, 2010 12:52 PM
|
|
|
|
|
Hi,
Did you try to find out if if any dependencies are missing or are out-of-date? As you may know, your library may be in place while some of its dependencies not.
Should you consider to try that, you could use depends.exe from sysinternals
SkyWalker
|
|
|
|
|
Hi everybody. I'm tring to save image form webBrowser control. and i have the following code
mshtml::HTMLDocument^ document = dynamic_cast<mshtml::HTMLDocument^>(this->webBrowser1->Document->DomDocument);
mshtml::IHTMLElementCollection^ collImages = document->getElementsByTagName(L"img");
for(int i = 0; i < collImages->length; ++i)
{
mshtml::IHTMLImgElement^ img = safe_cast<mshtml::IHTMLImgElement^>(collImages->item(nullptr, i));
mshtml::IHTMLElementRender^ render = dynamic_cast<mshtml::IHTMLElementRender^>(img);
Bitmap^ bmp = gcnew Bitmap(img->width, img->height);
Graphics^ g = Graphics::FromImage(bmp);
IntPtr hdc = g->GetHdc();
render->DrawToDC(hdc);
g->ReleaseHdc(hdc);
delete g;
g = nullptr;
bmp->Save(L"C:\\Test\\SaveImage.Jpg", System::Drawing::Imaging::ImageFormat::Jpeg);
}
I get the following error message
Error C2664: 'mshtml::IHTMLElementRender::DrawToDC' : cannot convert parameter 1 from 'System::IntPtr' to 'mshtml::_RemotableHandle %'
is there any one who knows how to fix this?
|
|
|
|
|
Yes, find out what type parameter DrawToDC expects.
It should be in the docs for IHTMLElementRender::DrawToDC.
|
|
|
|
|
Hi,
Ik have a form containing a number of comboboxes, called cmb1, cmb2, etc.
I want to loop through these boxes to set their itemlist. I have tried the following code:
for each (Control^ box in this->Controls){
if (box->GetType() == ComboBox::typeid){
box->Items->Clear();
}
}
This works fine, except that I cannot access the combobox's Items property. I can for instance access the Text property, so I think it's strange that the Items property is missing.
Does anyone have an idea how to solve this?
Thanks!
|
|
|
|
|
The reason you can't access the Items property is because you have declared box as a Control and Control doesn't have an Items collection.
You would have to declare a new variable as ComboBox and cast box into it:
for each (Control^ box in this->Controls){
if (box->GetType() == ComboBox::typeid){
ComboBox^ combo = (ComboBox^)box;
combo->Items->Clear();
}
}
modified on Friday, June 4, 2010 11:46 AM
|
|
|
|
|
Have you tried this code
for each(ComboBox^ box in this->Controls)
{
if(box->GetType() == ComboBox::typeid)
{
box->Items->Clear();
}
}
|
|
|
|
|
voo doo12, I've tried this, but when I run the program I get an error that says: "Unable to cast object of type 'System.Windows.Forms.Button' to type 'System.Windows.forms.ComboBox'.
So it seems that if the program encounters a control which is not a ComboBox it cannot deal with it in this way.
|
|
|
|
|
Richard, this makes sense. However, when I compile this code I get:
error C2440: 'type cast' : cannot convert from 'System::Windows::Forms::Control ^' to 'System::Windows::Forms::ComboBox'
Any idea how to solve this?
|
|
|
|
|
Solved!
I made a typo in Richard's code (forgot the ^ symbol in the cast part).
Now it works, thanks a lot for your help!
|
|
|
|
|
Glad to be helpful.
|
|
|
|
|
Hi everyone !
Please help me , because i have a big trouble !!!
I have login form , and i want to open form1 Form from login form.
I tryed use #include "Form1.h" in "login.h" login form where is.
Unfortunately i had problems and many mistakes such like :
Error 198 error LNK2005: "int SymulacjaObiektuSISO::i1" (?i1@SymulacjaObiektuSISO@@3HA) already defined in Logowanie.obj Symulacja Obiektu SISO.obj Symulacja Obiektu SISO
Error 199 error LNK2005: "int SymulacjaObiektuSISO::i2" (?i2@SymulacjaObiektuSISO@@3HA) already defined in Logowanie.obj Symulacja Obiektu SISO.obj Symulacja Obiektu SISO
Error 214 error LNK2005: "class std::deque<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > SymulacjaObiektuSISO::nazwyGeneratorow" (?nazwyGeneratorow@SymulacjaObiektuSISO@@3V?$deque@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@A) already defined in Logowanie.obj Symulacja Obiektu SISO.obj Symulacja Obiektu SISO
and i think this is because of #include files which are in form1.h
unfortunately i can't open form1 from login form : Form1^ test = gcnew Form1^();
i don't know what to do... please help me because i must do this !!!!
How can i resolve this problem ??
Login form -> open form1 form , and form1.h has the others #include files just like "test1.h" and ect.
Plese help me as fast as You can
|
|
|
|