|
Hi Muammar,
if you have a managed EXE/DLL calling unmanaged code in a DLL, then and only then you
need the DllImport and the static external stuff (on the managed side), and you must
worry about name mangling if the unmanaged code is C++.
if both parts are managed, you don't use DllImport, you don't use external.
You just use the type(s) from the DLL as if they are part of your EXE.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Hi Muammar©,
As you mentioned, it seems like the DLL you have is written in C# or .Net somehow, because as much as I know, working with string types is not as easy as C# in C and C++ and the Entry Point you mentioned makes me feel like the library you have is written in C# and in that case:
It you want to access the library at design time (coding time) you just need to add it to your project as a reference and use it by adding it's main namespace to your code, using the "using" keyword and then you can easily access the method you like.
But if you want to access it at runtime (directly from your compiled code) you need to know about the System.Reflection namespace and much more to use the classes inside it. You can find what you need on MSDN and google.
Good luck and have fun.
Sojaner!
|
|
|
|
|
Hello,
I encountered strange situation. Let's say we have a code like this:
<br />
string s = "123abc456";<br />
s.Remove(3, 3);<br />
Console.WriteLine(s);<br />
and the printed result is: 123abc456
I wonder why?
Thank you,
Dj_Lord
Dj_Lord
|
|
|
|
|
Because string.Remove returns a string. Change it to
s = s.Remove(3, 3); and please change the variable to a meaningful name; s just sucks.
|
|
|
|
|
Strings are immutable ( you can't change the value of a string, you can only generate a new string with a changed value ). So, ALL methods like substring, remove, replace, all return a new string with the changed value.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi
When play with string
you must override the string by your change string variable.
what I'm saying
s=s.Remove(3,3);
|
|
|
|
|
|
Override means
for example
string name = string.Empty;
name = "codeproject";
name = name.Remove(2,3);
Console.WriteLine(name);
output:coroject
|
|
|
|
|
I think you meant "overwrite"...
Oh well, semantics schmantics...
|
|
|
|
|
I have posted a sample for your references.
please check that.
|
|
|
|
|
No, that's creating a new instance of an immutable object.
Override has nothing to do with that.
|
|
|
|
|
I found this: http://www.codeproject.com/KB/IP/ListNetworkComputers.aspx on CP but it doesn't work with Mono in Ubuntu (I get a DllNotFoundException). I know there is the static method in the Dns class GetHostEntry (string ip_address) but sometimes it doesn't get the hostname of computers that are on. Is there some other way to get all the hostnames in a network without using an external dll?
I know I can use the code that was used in the mentionned article on Windows computers, but I'd like a method that work work in Ubuntu as well.
|
|
|
|
|
I want to enumerate all form controls on a user control that inherits from another user control (which also has controls on it). Here's some sample code. UserC in this sample is the user control which inherits from the base class user control.
int BindingFlags = Reflection.BindingFlags.Instance | Reflection.BindingFlags.Public | Reflection.BindingFlags.NonPublic;
foreach (System.Reflection.FieldInfo fi in UserC.GetType.GetFields(BindingFlags)) {
object obj = fi.GetValue(UserC);
if (obj != null)
{
try {
obj.Name();
}
catch (Exception ex) {
}
}
}
This will list all the form controls on the UserC class designer but not the base class it inherits from. You can see them all when debugging. What gives?
|
|
|
|
|
How would I add a timer to this? To keep things simple, I have a form with 1 button and 1 textbox. I have a messagebox that pops up when the textbox loses focus ... if the user clicks OK, it does something. However, if the user doesn't click OK within 3 seconds, I need the box to close and do something else. This is for a mobile app using .NETCF 3.5. Here's what I have so far in regards to the messagebox:
private void TextBox1_LostFocus(object sender, EventArgs e)<br />
{<br />
<br />
DialogResult result = MessageBox.show("message text","title",MessageBoxButtons.OK,MessageBoxIcon.None,MessageBoxDefaultButton.Button1):<br />
<br />
if (result == DialogResult.OK)<br />
{<br />
Button1.Focus();<br />
}<br />
else<br />
{<br />
}<br />
}
Any help would be appreciated! Thanks!
|
|
|
|
|
Most likely you'll need to create a Form that looks like a message box that has a timer on it. The built-in MessageBox is not very customizable outside of the text and icons.
|
|
|
|
|
|
|
|
Hi,
why is language that important? to learn concepts just read the text and look at the
program structure and the classes/methods used.
if you can write C# I trust you can also read VB code?
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
I can (sorta) comprehend what the VB code is trying to do, yes.
|
|
|
|
|
Hello,
I have here and than the following Problem:
I have a self-made control in a library that I use in my application. After a while the designer tells me, when I want to open the Form containing the Control, that he cannot convert type 'A' to type 'A', where 'A' is a own class that contains Data that can be changed with the control.
In the InitializeComponent() of the Form there is the call
this.theControl.TheA = ((A)(resources.GetObject("theControl.TheA")));
that I think causes the Problem. As with this the Data is serialized and deserialized, I believe that after changing the library that contains the control this serialize does not work in the same way (maybe the assembly version number is included?).
Is there a way to take control over the storing of complex data to not have it serialized in the .resx file?
Thanks for your help.
Greets
Roland
|
|
|
|
|
You can change the way the designer serializes TheA property by putting the following attribute on TheA property: [DesignerSerializationVisibility(...)]
Beyond that, if you want further control, you may need to have the control implement ISerializable and perform serialization that doesn't care about the version to get around this issue.
|
|
|
|
|
Thank you very much!
Greets
Roland
|
|
|
|
|
I gave up. How can I save back data to app settings. I'm doing it like this..but it's not working:
Configuration configManager = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
ConfigurationSectionGroup section = configManager.SectionGroups["applicationSettings"];
if (section != null)
{
ClientSettingsSection clientSettings = section.Sections["OutlookSync.Properties.Settings"] as ClientSettingsSection;
if (clientSettings != null)
{
SettingElement element = clientSettings.Settings.Get("hello");
element.Value.ValueXml.InnerText = "www";
configManager.Save(ConfigurationSaveMode.Full);
}
}
this is the section I'm trying to read
<br />
<applicationSettings><br />
<OutlookSync.Properties.Settings><br />
<setting name="hello" serializeAs="String"><br />
<value>hello</value><br />
</setting><br />
</OutlookSync.Properties.Settings><br />
</applicationSettings><br />
|
|
|
|
|
Hi,
Are you intending to save settings that are made during the execution of the programme? If so you should be using "userSettings". I think the "applicationSettings" section is intended to be read only and configured at design time or by manually editing the appname.exe.config file but I may be wrong on this.
The default values for user settings are stored in appname.exe.config but runtime changes are saved to user.config which resides deep down in a user's Local Settings directory.
The code to read and write user settings can be as simple as this.
String greeting;
private void ReadSettings() {
greeting = Properties.Settings.Default.hello;
}
private void WriteSettings() {
Properties.Settings.Default.hello = greeting;
Properties.Settings.Default.Save();
}
AlanN
|
|
|
|