|
Use Friend Assemblies: Friend Assemblies at MSDN[^]
Your functions and classes can only be used by assemblies using a certain namespace, further protection is done using keys. This does not prevent ILDASM from disassembling though.
To prevent ILDASM from disassembling it, add this: [assembly: SuppressIldasmAttribute()][^]
|
|
|
|
|
I experienced that from the other side: a long time ago, I tried to use a data mining dll from SQL Server in my application. When I instantiated the COM object, I got a message that I had no license to do so.
From that experience, I'd think of some licensing mechanism, likely with asymmetric encryption (only the "public" key would be stored somewhere in the application and could be read by reverse engineering).
The reference to your dlls could still be added, but they would not be useful.
|
|
|
|
|
You might want to look at the ILMerge tool.
|
|
|
|
|
Hi all,
I am currently trying to send a COM Event from a .NET Assembly to another application. Therefore I am applying the approach that's found multiple times across the internet. Here it's outlined for short.
[ComVisible(false)]
public delegate void OnNotifyDelegate();
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface Events
{
void OnNotify();
}
[Guid(EventSource.ClsID)]
[ClassInterface(ClassInterfaceType.None)]
[ComSourceInterfaces(typeof(Events))]
public class EventSource : ServicedComponent, EventInterface
{
private const string ClsID = "4A235195-E8B3-473b-8F14-F7F0ADFC40E0";
public event OnNotifyDelegate OnNotify;
public EventSource() { }
public void CauseOnNotify()
{
OnNotify();
}
}
Now, to raise the OnNotify Event I created a small WPF Application with a button, whose Click handler invokes the method CauseOnNotify above. I don't show it here, because that would be verbose.
What I get is a NullPointerException because OnNotify is at the time it's invoked null.
My question is: None of the examples mentions a instanciation of the delegate (which is why its null, but under which circumstances does this exception not happen? Where is the instance coming from?
thanks in advance
Lars
#pragma error( disable : * )
|
|
|
|
|
When some other object has registered for the event?
I haven't tested with COM, but it looks similar to raising a "normal" .NET event:
if (this.MyEvent != null)
{
this.MyEvent(this, new EventArgs());
}
Only after an object has registered for MyEvent, it is different from null.
|
|
|
|
|
Hello
In my program I dynamically load DLL, but I have some problem. Dll use my program config and not his own confg. Here is part of the code:
Assembly assemblyInstance = Assembly.LoadFrom(assembly);
Object ProviderClass = assemblyInstance.CreateInstance(type);
object[] methodMaramList = new object[1];
methodMaramList[0] = logInInfo;
if (providerInfo.GetInformation == false)
throw new Exception("This provider does not support get abonent function.");
authorizationResponse = (AuthorizationResponse)assemblyInstance.GetType(type).InvokeMember(method,
BindingFlags.Public |
BindingFlags.InvokeMethod |
BindingFlags.Instance,
null,
ProviderClass,
methodMaramList);
|
|
|
|
|
Which one of the code lines causes a problem? What's the error message?
What is "providerInfo"?
|
|
|
|
|
Hi,
When I try to enter ALT+1(Num Lock pad) in a text box, its loading as ☺ in textbox. How to avoid such symbols. I tried to avoid taking input from num lock pad and wrote the below code. But still its showing symbols. Please let me know how to avoid those. Thanks in advance
private void txtHotKey_KeyDown(object sender, KeyEventArgs e)
{
//for Num Lock keys 0-9
if (e.KeyValue==18 || e.KeyValue > 95 && e.KeyValue < 106)
{
return;
}
}
|
|
|
|
|
Pressing Alt with the number keys generates special characters with the value of the keys pressed. So for example Alt+65 would give the character A which has the decimal value 65 (hex 41).
I must get a clever new signature for 2011.
|
|
|
|
|
thats fine.. But how to avoid those special symbols programmatically.
|
|
|
|
|
HaroldVish wrote: But how to avoid those special symbols programmatically
You shouldn't. The facility is provided to allow people to enter codes which are not directly available from their keyboard: À rather than A for example. It you cut down on what a user is used to doing, then they will probably get frustrated and annoyed with your program.
Imagine for example, that someone wishes to enter Arabic or Chinese characters: should you stop that, too?
Why are they causing you a problem?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
Did you notice that little KeyEventArgs thingy in the KeyDown handler? it has some properties and some methods, you need one of each: Handled and SuppressKeyPress() . Use Google and read the documentation.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hi,
Create a function which scan all text char and check whether it is a special character or not, if it is then remove the character. Call this function on the leave event or text change event.
C#, VB.NET,ASP.NET DEVELOPER
|
|
|
|
|
hi
looking for how to make my own MessageBox sample code
something simple that has title, body text and yes/no button
and how to use it
thanks in advance
|
|
|
|
|
|
Why would want to reinvent the wheel?
|
|
|
|
|
|
Hello all,
i'm trying to do sequential reading from a OleDbDataReader that is retrieving an xml stream generated (string) in the sql server but i end up with an invalid cast exception.
The same code works like a charm using SqlDataReader, but for some reason, i had to integrate with another connection object and retrofit the code to use OleDbDataReader.
Have anyone ever experienced something like this?
_reader = _command.ExecuteReader(CommandBehavior.SequentialAccess);
while (_reader.Read())
{
_index = 0; ;
_read = _reader.GetChars(0, _index, _chbuff, 0, BUFF_SIZE);
while (_read > 0)
{
_writer.Write(_chbuff, 0, (int)_read);
_writer.Flush();
_index += _read;
_read = _reader.GetChars(0, _index, _chbuff, 0, BUFF_SIZE);
}
}
|
|
|
|
|
Use pre tags. Where does the error happen? What are the data types?
I've never heard of someone trying to do what you're trying to do; it looks weird.
|
|
|
|
|
Say I have two datagridviews (DG1, DG2) each with its own contextmenu, (Menu1,Menu2). Menu1 has menu items Save,Delete,Print and Menu2 has Save,Delete,Print now I would like to make one function that looks like
private void Context_Menu_Save(object sender, EventArgs e){
DataGridView DG = (DataGridView)sender;
}
and then do what I need to do.
The problem is that sender is the menuitem not the Datagridview that menuitem is associated with, so how do I find out which DataGridView's context menu was selected?
|
|
|
|
|
Here are a couple of ways to overcome your problem:
1. the MenuItem belongs to some top-level menu, use its Parent property to find that top-level menu (the ContextMenu might be hierarchical); once you found the ContextMenu, that one has a SourceControl property which will point to the Control on which you right-clicked.
2. you could use the Tag property of the MenuItem and store something there, e.g. the underlying Control.
3. you could set up a dictionary that maps MenuItems to Controls.
4. you could organize a class member "lastDataGridViewClicked" and set it in the MouseDown handler of all DGVs.
#1 requires no set-up effort, it does need a loop to cope with hierarchical menus though.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Did you check the EventArgs? Sometimes they stuff things in like the OriginalSource, etc. Besides, how are you throwing up the context menu?
|
|
|
|
|
Yes I looked in the eventargs didn't see anything in there either.
And I'm throwing up the context menu via right click. (Not sure if that is what your asking)
But I solved the problem by using the Tag property as suggested earlier.
|
|
|
|
|
Try this:
ToolStripMenuItem itm = sender as ToolStripMenuItem;
if (itm != null)
{
ContextMenuStrip cm = (ContextMenuStrip)itm.Owner;
MessageBox.Show(cm.SourceControl.ToString());
}
Obviously I'm only showing the control in a MessageBox . You can do whatever you need to with it.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
I wouldn't let CG touch my Abacus!
When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.
|
|
|
|
|
hi
i made message-box -> a form that has label for message and label for title
and OK button (do nothing).
i can rise this message from any form in my program.
i need message-box that has yes button and no button, and to know
if it pressed yes or no
how to do it ?
can i get any sample code for this ?
|
|
|
|