|
You can't run a dll. You write an app that imports the dll, and calls methods in it.
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 Chris
then how my application run the dll that is downloaded by the System Configurator
wasim khan
|
|
|
|
|
Your app can probe any dll via reflection, or it can be built to import a dll, then it can call it directly.
Well, so long as it's a .NET dll. otherwise, you can p/invoke or call via COM, but you can't reflect, so you'd need to know about it at compile time.
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 )
|
|
|
|
|
use unmanaged code to access your dll and use managed or direct call to your method
example
using System;
using System.Runtime.InteropServices
class UnmanagedAccessDll
{
[DllImport("myDll.dll")]
public static extern void StartWizard([required parameters if any]);
}
public ManagedAccessDll
{
public void Startwizard([required parameters if any]){
UnmanagedAccessDll.Startwizard([required parameters if any]);
}
}
or you can call directly in your code
...
UnmanagedAccessDll.Startwizard([required parameters if any]);
...
|
|
|
|
|
can someone know how to put a code on a treeview node??
where can i find the mdichild form..
there is no mdi child form on the when i clicked project then add form..
ginji
|
|
|
|
|
Do you mean how to create a TreeNode in code and add it to a TreeView? If so:
TreeNode node = new TreeNode("Node Text");
treeView1.Nodes.Add(node);
MDI children are just normal forms which is why there's no automatic MDIChildForm option.
Set the parent form's IsMdiContainer property to true, and after you instanciate the child form, set it's MdiParent property to the parent form. i.e.
Form2 form2 = new Form2();
form2.MdiParent = this;
form2.Show();
Dave
|
|
|
|
|
i mean how to put a code in a node for example if i click node1 another form opens then if i click node2 the form is disabled...
mdichild
thanks i created a mdi child form can i also how can i close the mdichild form and goes back to the mdiparent because if i hide the mdichild the mdiparent also hides.
modified on Wednesday, June 25, 2008 9:27 PM
|
|
|
|
|
A little background.
I'm playing with BusinessObject s and Factory (s) which contain collections of BusinessObject s.
My business objects all derive from a BusinessObjectBase class.
I have an IBusinessObjectBase interface, which the BusinessObjectBase implements.
My factory objects all derive from a FactoryBase class.
The FactoryBase class is generic (FactoryBase<T> where T : IBusinessObjectBase )
I have an IFactoryBase interface, which the FactoryBase impliments.
public interface IFactoryBase<T> where T : IBusinessObjectBase
Everything works fine (I'm not sure if the model is a little simplistic maybe)
Now.
I'm wanting to create a status bar, which displays a few properties from the current BusinessObject , and the currenct Factory (Like data errors, read only info etc.).
So I created a test to see how to go about this, but encountered a problem.
customerFactory cFact = new customerFactory();
if (cFact is IFactoryBase<IBusinessObjectBase> ) TestContext.WriteLine("IFactoryBase supported");
if (cFact is IComponent) TestContext.WriteLine("IComponent supported");
if (((IFactoryBase<IBusinessObjectBase> )cFact).IsClean) TestContext.WriteLine("Factory is clean");
customerFactory is derived from FactoryBase, and does indeed support the IFactoryBase interface.
public class customerFactory : FactoryBase<customer>
The customer object is derived from BusinessObjectBase , and supports IBusinessObjectBase
The first line, fails even though my Factory does support the interface.
The second line succeeds (IComponent is indeed supported)
And the third line fails to cast.
Many thanks.
|
|
|
|
|
stovesy wrote: My factory objects all derive from a FactoryBase class.
The FactoryBase class is generic (FactoryBase<t> where T : IBusinessObjectBase)
I have an IFactoryBase interface, which the FactoryBase impliments.
public interface IFactoryBase<t> where T : IBusinessObjectBase
You cant just implement the interface and expect it to magically become one!
FactoryBase should be declared as:
class FactoryBase<t> : IFactoryBase<t> where T : IBusinessObjectBase ...</t></t>
|
|
|
|
|
As stated above, the FactoryBase class, does implement the IFactoryBase interface, I've just not show that in code.
Cheers.
|
|
|
|
|
stovesy wrote: I've just not show that in code.
Then dont complain at my answer. If it indeed is a FactoryBase derived object it has to be IFactoryBase then, and you have made a mistake somewhere.
|
|
|
|
|
You misunderstand - I'm not complaining about your answer, just clarifying things.
Thanks for your interest.
|
|
|
|
|
stovesy wrote: IFactoryBase<ibusinessobjectbase>
IFactoryBase<customer> is needed then.
|
|
|
|
|
We're getting to the crux of the matter.
What you suggest does work, but I don't know the type of the generic class, only that it derives from IBusinessObjectBase
So when I try ...(customerFactory is IFactoryBase<ibusinessobjectbase>).... it fails.
Thanks for your time
|
|
|
|
|
stovesy wrote: We're getting to the crux of the matter.
Indeed
stovesy wrote: What you suggest does work, but I don't know the type of the generic class, only that it derives from IBusinessObjectBase
So when I try ...(customerFactory is IFactoryBase).... it fails.
Why not make IFactoryBase non-generic, and expose the non-generic properties/methods you need to access? Else create a non-generic IFactoryBaseBase interface
|
|
|
|
|
I have changed as you suggest, and it does work.
I still wonder why I can't do the generics thing - seems more elegant.
One for the back-burner maybe.
Thanks for your help.
|
|
|
|
|
Generics having full covariance is a common expectation, and I find the easiest way to explain it is to give a counter-example.
Say you have IBusinessObject< T > { IList< T > ListOfChildren; }.
So with our IBusinessObject< Customer > foo, we can .ListOfChildren and get a IList< Customer >.
Good so far.
Then if we could cast foo to IBusinessObject< object > - if we did .ListOfChildren we could have a IList< object >.
Still everything is peachy until we take that IList< object > and break type-safety by doing .Add(someRandomObject). We obviously can't actually Add any object to that IList, it must be a Customer. So IBusinessObject< object > is not an equivalent type.
IIRC the compiler can be nice to us and provides covariance in the case of a "read-only" generic type, identified by the type parameter being used for read-only properties, and return values only. IEnumerable< T > is probably one of these.
So in summary, IFactoryBase< Customer > cannot be cast to IFactoryBase< IBusinessObjectBase >, they are different types - it is specialized in dealing with Customers, not any IBusinessObjectBase. You might be able to get away with it if IFactoryBase< T > only uses T on the return side of it's members (like IEnumerable< T >), but I'm not sure if this behaviour is fully documented/guaranteed. (Check for me and reply? )
|
|
|
|
|
Thanks Mark.
The way of looking at it that sits well in my brain - I was seeing a generic type definition as two types: clear now that this is not the case.
You do learn something every day.
|
|
|
|
|
Hi,
I have developed a winform application which monitors files using FileSystemWatcher. This works fine.
Now I have to develop it in Windows service.
Can you see why the following line does not compile in windows service please?
//in winform I am using this which works fine...
_watcher.SynchronizingObject = this;
//this line does not compile in windows service. Please note I changed the word this to the service class name i.e. FileMonitor
_watcher.SynchronizingObject = FileMonitor;
The error is: FileMonitor.FileMonitor is a type but it's used as a variable.
|
|
|
|
|
arkiboys wrote: //in winform I am using this which works fine...
_watcher.SynchronizingObject = this;
//this line does not compile in windows service. Please note I changed the word this to the service class name i.e. FileMonitor
SynchronizingObject is not needed outside a WinForm project. It is simply there to prevent cross threaded calls. You can safely ignore that in a Window Service.
|
|
|
|
|
you need to assign the actual instantiated variable and not the class.
IE
FileMonitor FM = new FileMonitor();
_watcher.SynchronizingObject = fileMonitor;
Regards
Michael
|
|
|
|
|
I wanted to use the Regex.Split function to split an incoming string up. The problem is that the string parts are separated by a pipe | but the pipe is used inside the Split function to split different separators (e.g. if you want to split on dash and space you would write it as " |-" ). So when I use "|" the string splits into it's characters. I tried using "\|" but this is considered an Unrecognized Escape Character and doesn't compile.
Does anyone know if this is possible in another way?
|
|
|
|
|
You have to encode the characters in the expression twice. First you have to encode the pipe to put it in the regular expression, then you have to encode the regular expression to put it in a literal string in the code.
Use \\| in a regular literal string, or \| in an @ delimited string.
Example:
string pattern = "\\|";
or
string pattern = @"\|";
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks, that solved the problem
|
|
|
|
|
public string deleteDB(string strSelect)
{
try
{
cmd.Connection = objConn;
cmd.CommandText = strSelect;
cmd.ExecuteScalar();
}
catch (SqlException eException)
{
Console.Write("Error in connection : " + eException.Message);
return -10;
//return strSelect;
}
}
|
|
|
|