|
N a v a n e e t h wrote: You can trust me
N a v a n e e t h wrote: But if you take a look at C++/CLI's standard, you will not find anything related to extension method. And a search on the web also tells the same.
So true!
N a v a n e e t h wrote: What it doesn't understand is to look for this specific attribute and show the method as an extension. This is simply because it is not implemented in the compiler.
You know what.
I just wanted to ask you rereading the article, but as I was looking over it once again I found out that I completely missunderstood a sentence in the section "Making an Extension Method in C++/CLI".
About "ExtensionAttribute":
"Applying the attributes to the proper place in the C++/CLI project, I was able to get the extension method to show up"
Yes, but only with the C# compiler, and not with the C++/CLI compiler.
N a v a n e e t h wrote: It was a good read. Thanks for the link.
It seems, that I learned more new stuff from providing that article, than you reading it!
With your help, I think I got it now! Thank you!
My conclusion about the .Net implementation of extension methods:
All the best,
Martin
|
|
|
|
|
I was a little confused by your original question, but if are are trying find out if it is possible to <b>implement</b> extension methods in C++/CLI (that can be consumed from VB and C# as extension methods), the answer is yes.
You just declare a C++/CLI class that is both abstract and sealed, and you apply the [Extension] attribute to both the class and the extension methods you add to it, which must be public and static. The extension methods themselves do not use the 'this' keyword like they do in C#, but they're seen as extension methods by the VB and C# compilers. The example below implements a "Matches()" method for System.String:
<pre>
#pragma once
using namespace System;
using namespace System::Runtime::CompilerServices;
using namespace System::Text::RegularExpressions;
namespace System
{
[System::Runtime::CompilerServices::Extension]
public ref class StringExtensionMethods abstract sealed
{
public:
[System::Runtime::CompilerServices::Extension]
static bool Matches( System::String^ string, System::String^ pattern )
{
return Regex::IsMatch( string, pattern );
}
};
}
</pre>
|
|
|
|
|
tonyt wrote: I was a little confused by your original question
Me too!
Thanks for the summary, but I finally understood all that!
You get my 5 for careing that much.
All the best,
Martin
|
|
|
|
|
I have a “NativeToManaged.dll”, which is full of native code (no managed code, it generated LIB file for exported native class).
I used it in a test application, which is managed (C++\CLI). I could use the exported class form “NativeToManaged.dll” and works fine in RunTime.
Now I added some managed code (C++\CLI) in “NativeToManaged.dll” and made the project settings to “Common Language Runtime Support (/clr)”. I didn’t modify anything in test application. It compiled fine. But while in RT it throws an exception
“An unhandled exception of type 'System.IO.FileLoadException' occurred in testInt.exe”
“Additional information: Could not load file or assembly NativeToManaged, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Could not find or load a type. (Exception from HRESULT: 0x80131522)”
Help me to fix this problem
VIBIN
"Fool's run away,where angle's fear to tread"
|
|
|
|
|
We're having a problem on a few client machines where our managed C++ MFC app will not start. Its a managed c++ app linked to some C# dlls. It won't even hit the constructor or OnInitApp.
Its almost identical to this: http://www.eggheadcafe.com/community/aspnet/36/10076902/mixed-c-managed-c-c.aspx[^] but of course there was no solution posted.
I have one of the offending machines and it starts in safe mode, but not when starting windows normally. I have also shutdown nearly every service, including anti-virus apps. It seems like something is blocking it but everything that possibly would be blocking it has been turned off.
Tried running the CLR Profiler with the app but the clr doesn't start.
Any clue's as to what is causing this would be appreciated.
Thanks
"Make everything as simple as possible, but not simpler." - Albert Einstein Jason Henderson
|
|
|
|
|
Jason Henderson wrote: Tried running the CLR Profiler with the app but the clr doesn't start.
Can you run any other .NET application on this machine? If not, I guess the problem will be with the setup of .NET framework.
Best wishes,
Navaneeth
|
|
|
|
|
While looking for some tool to help I installed PerfMon which I believe is a .net app and it ran fine. All of our other native apps run fine as well.
"Make everything as simple as possible, but not simpler." - Albert Einstein Jason Henderson
|
|
|
|
|
|
It gets installed in our software's installation script, but I reinstalled it anyway. Didn't help.
"Make everything as simple as possible, but not simpler." - Albert Einstein Jason Henderson
|
|
|
|
|
Two things may help you:
1.Use Depends(dependency walker) on the cli module.
I beleive that you will find a missing environment path or a missing dll that you assumes you have.
2.Try Fusion Log - it will give you an indication of .net binding errors.
Good luck,
Yoav
|
|
|
|
|
Hi All,
I am working on windows platform with no administrative privileges. I want to send messages/files from my pc to another in LAN. I am using one software 'IP Messanger' which doesn't required any privileges to install it or to send messages/files from one pc to another in LAN. I know DOS commands like 'send','msg' etc. but they need 'Messenger' to be on. My pc's 'Messenger' is off but still 'IP Messenger' works fine. How can the software work well without turning 'Messenger' service on ? Also i want know that, is there any method/command available in DOS to send messages/files without 'Messenger' service?
Thanks
Nilesh
|
|
|
|
|
I don't think this is the right place to post this question.
|
|
|
|
|
I already responded to this question here[^]. If you have supplementary queries then post them in the original thread, do not start a new thread with the same question.
|
|
|
|
|
hummmmm. but i was looking for some more different answers...
|
|
|
|
|
Nilesh Hamane wrote: i was looking for some more different answers.
What does this mean? Your question has been answered according to the information you provided, I have no idea what more you need to know. If you have a specific problem with your own programs then you can post them here. If you have a problem with someone else's programs then you should try asking the provider. For example, if IP Messenger has some issues then try asking the people who wrote the program for help.
|
|
|
|
|
Actually what i'm trying to do is to get a multiline rows selection without the problem of holding the ctrl key (i'm developing a touchscrenn app).
By now i quite get it with a list of selected lines, but if i try to click fast on the rows it give me some painting error. Can someone give me a hint. (Maybe i should fire the ctrl command? i don't know how to simulate the pressdown command )
#ifndef _CSTDGV_
#define _CSTDGV_
namespace primoAlpha {
using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;
using namespace System::Security::Permissions;
public ref class personalDataGridView : DataGridView
{
public:
personalDataGridView()
{
this->selectedRowIndexes=gcnew Collections::ArrayList();
this->MultiSelectForced=false;
}
property bool MultiSelectForced
{
bool get() {
return _MultiSelectForced;
}
void set(bool value) {
this->_MultiSelectForced = value;
this->selectedRowIndexes->Clear();
processSelectedRowIndexes();
}
}
protected:
virtual void OnCurrentCellChanged (EventArgs^ e) override
{
if (this->CurrentRow!=nullptr && _MultiSelectForced) {
int act_row=this->CurrentRow->Index;
if (selectedRowIndexes->Contains(act_row)) {
selectedRowIndexes->Remove(act_row);
}
else selectedRowIndexes->Add(act_row);
processSelectedRowIndexes();
}
DataGridView::OnCurrentCellChanged(e);
}
private:
Collections::ArrayList ^selectedRowIndexes;
bool _MultiSelectForced;
void processSelectedRowIndexes() {
this->SuspendLayout();
this->ClearSelection();
for (int i=0;i<selectedRowIndexes->Count;i++) {
if (selectedRowIndexes[i]!="0") {
this->Rows[Convert::ToInt32(selectedRowIndexes[i]->ToString())]->Selected=true;
}
}
this->ResumeLayout();
}
};
}
#endif
|
|
|
|
|
Ok i find myself the solution...if you need...
#ifndef _CSTDGV_
#define _CSTDGV_
namespace primoAlpha {
using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;
using namespace System::Security::Permissions;
public ref class personalDataGridView : DataGridView
{
public:
personalDataGridView()
{
this->selectedRowIndexes=gcnew Collections::ArrayList();
this->MultiSelectForced=false;
}
property bool MultiSelectForced
{
bool get() {
return _MultiSelectForced;
}
void set(bool value) {
this->_MultiSelectForced = value;
this->selectedRowIndexes->Clear();
processSelectedRowIndexes();
}
}
protected:
virtual void OnCellMouseDown(DataGridViewCellMouseEventArgs^ e) override
{
DataGridView::OnCellMouseDown(e);
if (e!=nullptr && _MultiSelectForced) {
int act_row=e->RowIndex;
if (selectedRowIndexes->Contains(act_row)) {
selectedRowIndexes->Remove(act_row);
}
else selectedRowIndexes->Add(act_row);
processSelectedRowIndexes();
}
}
virtual void OnMouseMove(MouseEventArgs^ e) override
{}
private:
Collections::ArrayList ^selectedRowIndexes;
bool _MultiSelectForced;
void processSelectedRowIndexes() {
this->SuspendLayout();
this->ClearSelection();
for (int i=0;i<selectedRowIndexes->Count;i++) {
if (selectedRowIndexes[i]!="0") {
this->Rows[Convert::ToInt32(selectedRowIndexes[i]->ToString())]->Selected=true;
}
}
this->ResumeLayout();
}
};
}
#endif
|
|
|
|
|
Hello. I posted this here because I noticed this issue first while working on a C++/CLI project. But it equally applies to C#.NET projects which makes me think it's a general .NET issue.
Has anyone had troubles with the Form.StartPosition property value CenterParent in Windows 7? I know my invoking code is fine because I started this project on WinXP and everything was happy. Code like this in the main application form:
MyForm^ f = gcnew MyForm();
f->Show(this);
Despite the fact that I'm passing the reference to the parent in the Show() call, the child form shows up in the upper left corner rather than the center of the parent.
Any ideas?
Thanks in advance.
modified on Wednesday, December 9, 2009 3:34 PM
|
|
|
|
|
What happens if you explicitly set the Parent property
of MyForm before calling ShowDialog()?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
First, I have to correct myself. The problem is in Show(), not ShowDialog(). I tried to explicitly set the parent ahead of time like this:
MyForm^ f = gcnew MyForm();
f->Parent = this;
f->Show();
Doing so gave me a runtime error at the line where I set the Parent property:
ArgumentException: Top-level control cannot be added to a control.
|
|
|
|
|
Xpnctoc wrote: ArgumentException: Top-level control cannot be added to a control.
Maybe set TopLevel to false?
MyForm^ f = gcnew MyForm();
f->TopLevel = false;
f->Parent = this;
f->Show();
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
That didn't fly either. I didn't get an error, but the child window just plain didn't show up anywhere on the screen, taskbar, or anywhere else.
|
|
|
|
|
It was worth a try... I don't know what your parent window
is so I was just guessing, based on the fact there's a difference
between "parent" windows and "owner" windows.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Well maybe that's part of my problem. I wasn't aware there is a difference. Could you explain that or provide a link that would elaborate on that more?
|
|
|
|
|
I would start in the Form class properties[^]
(Owner and Parent).
Also maybe search on ".net parent vs owner" or similar.
What are you using as a parent? A Win32 window (HWND) or another
Form/Control?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|