|
You're gonna have to redistribute the .Net framework, largely because MS hasn't really pushed it to end-users yet.
There is an app I downloaded a day or two ago that allowed you to take only the portions of the .Net framework that your app uses and bundle it inside your executable (along with any other dlls needed by your app). Can't remember the name of it offhand...maybe someone else knows it.
The graveyards are filled with indispensible men.
|
|
|
|
|
Besides the .NET Framework (which MUST be installed), you can use touchless deployment by writing your application correctly, i.e. rely on .config files only (no registry).
The application I architected runs both from local or LAN machines, or from across the Internet or an intranet with no change. The assembly binding uses the current codebase of the application plus any private paths your config files specifies (see the <runtime> section documentation in the .NET Framework SDK).
You also need to worry about code access permissions, though. In .NET 1.0, the default Internet Zone allows no code to run. In .NET 1.1 some basic permissions are granted to code running from the Internet. You can change or add these code policies, though. There is plenty of documentation about code access security in the .NET SDK Documentation. Just look for "code access security". I'm also working on an extensive article or chain of articles but it'll be some time.
It's important to read, though, because you really must understand them before using them. You don't want to open someone's machine to attach by accident, and you want to make your application work with different permissions granted, i.e. some are required and some are optional. Take a look at the System.Security.Permissions namespace classes for more information about this stuff, as well as the documentation for code access security.
If you don't need to run from a remote source, you don't necessarily have to worry about it (although it's still a good idea to check permissions in your app before executing an action that requires them, otherwise a SecurityException is thrown). Just use COPY/XCOPY to copy your apps and dlls to the local machine and make sure they are in the right place. You can leave all the exes and dlls together with no problem. You can use the application configuration file to specify additional paths, similar to what ASP.NET Web Matrix does.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
For example,to add a new toolButton in the ToolBar of printPreviewDialog ,or add a new label or textBox in it.
thanks a lot.
|
|
|
|
|
You'll need to derive from PrintPreviewDialog and use a combination of adding and removing controls with the Controls collection property, and overriding the WndProc to handle lower-level functions.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
i have to protect my program so please if some one know any way to protect it from being coppied to another computer maybe( we use the computer number).
|
|
|
|
|
Take a look at my article at http://www.codeproject.com/dotnet/xmldsiglic.asp[^]
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
HI ,
I have made a procedure for sql server with visual c++ and i have test it on my computer and it is well but when i have move it to the server it could not work and it give me the following error
ODBC: Msg 0, Level 16, State 1
Cannot load the DLL sim.dll, or one of the DLLs it references. Reason: 126(The specified module could not be found.).
can any body help me
|
|
|
|
|
First, make sure it's in the Binn directory for the appropriate SQL server instance. I'm sure you've problem done that.
The big thing to remember is that servers often don't have the latest and greater technologies - only that which is required to run. My common mistake (I seem to make it every time but quickly realize what's wrong) is that I developed XP's in VS.NET 2002 or 2003 which uses the VC++ runtime 7.0 or 7.1 respectively. Our SQL Server doesn't have either of those runtimes. This is most likely your problem.
You can either "blindly" copied msvcr70.dll or msvcr71.dll and any other dependencies to %WINDIR%\System32 or to the appropriate Binn directory (or anywhere else in the %PATH%, although those two places are the logical choices). To make sure you get all the dependencies, run depends.exe (from the Platform SDK which was probably installed with your Visual Studio or is available for free online) on your XP (extended proc, not Windows XP ) and see what is required. Make sure those files exists on the server somewhere in the %PATH%. You could also copy depends to the server and run it on your XP from there - it'll tell you what's missing.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
thanks v.much it was the msvcr71.dll missing file on the server, but the strange thing that i have use wise installer to install that library from it, i have make an installation file which contain the merge module of VC++ library and it did not work so when i have copy the file to the server it works so thank you for your help and in the next time i will write this question in the SQL section
|
|
|
|
|
The merge module probably doesn't contain the right version of the VC++ runtime. To my knowledge (and I've beta tested and used WFWI since before 1.0), they have not yet released MSMs for newer runtimes (???). If they have, make sure you use the right MSMs. If nothing else, nothing special is needed to just copy them to the [SystemFolder] directory.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Oh...and wrong forum! This would be better in the VC++ or SQL forum (and more is more likely to get answered there). Just for future reference...
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
When I try writing a mathematic expertion with a right to left language in textbox or list box arrange of words change and expertion left to right arrange (for mathematic expertion) change to rihgt to left and it will be more confusing and not readable please tell me how I can stop this conversion
|
|
|
|
|
FWIW, I think you mean "expression".
The problem is simple. While every other control mode is a right-to-left reading order, simply make that TextBox read from left-to-right by setting TextBox.RightToLeft (inherited from Control ) to RightToLeft.No . If you read the documentation for the RightToLeft enumeration, you'll see the "rules" for how the RightToLeft property is resolved. By setting this property to "No", it will always read from left-to-right.
If the TextBox could have other text besides a mathematical expression, then you'll need to do some checking. You could handle the TextChanged event and parse the text to see if it contains a methematical expression. If it does, then change the RightToLeft property accordingly.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Is MS Access "Transaction Aware"?
|
|
|
|
|
You can make transactions in access DB..
in classic ADO :
con.BeginTrans<br />
..if things go right :<br />
con.CommitTrans<br />
..else<br />
con.RollbackTrans
where con is a connetion object.
|
|
|
|
|
so, I assume it can participate in a COM+ transaction?
|
|
|
|
|
I meant to say, can it participate in a COM+ transaction in following manner:
[Transaction(TransactionOption.Required)]
... other stuff ...
public class AccessDbManager
{
...
public void UpdateClientProfile(...);
public void UpdatePosition(...);
public void GetPosition(...);
...
}
I'm asking this because there's a piece of code that worked perfectly fine in a C# console app, but failed mysteriously when I embed it inside one method of a Transaction enabled serviced component... Here's the code. I tested it many times. It worked in a C# console app.
int count = -1;
string db_username;
string db_passwd;
int db_numlogin;
string connString;
OleDbConnection connUsers;
OleDbDataAdapter daUsers;
DataSet dsUsers;
EventLog log = new EventLog("Application");
log.Source = "AccessDbMaster";
try
{ //try block
retcode = -1;
connString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Program Files\SomeDir\datasource\users.mdb; User ID=Admin; Password=";
Trace.WriteLine(connString);
connUsers = new OleDbConnection(connString);
daUsers = new OleDbDataAdapter("SELECT * FROM Users WHERE username='"+ username + "' AND passwd='" + passwd + "'", connUsers);
dsUsers = new DataSet();
**********************************************************************
daUsers.Fill(dsUsers, "Users"); //BOOM. Failed here. "No error information available: E_NOINTERFACE(0x80004002)."
**********************************************************************
count = dsUsers.Tables["Users"].Rows.Count;
if(count==0) {
log.WriteEntry("AccessDbMaster authentication failed. User not found");
return;
}
foreach(DataRow user in dsUsers.Tables["Users"].Rows)
{
db_username = user["username"].ToString();
db_passwd = user["passwd"].ToString();
db_numlogin = (int) user["numlogin"];
retcode = db_numlogin; //return value
//Increment number of login:
db_numlogin++;
user["numlogin"]=db_numlogin;
}
OleDbCommandBuilder cmdBuilder = new OleDbCommandBuilder(daUsers);
daUsers.Update(dsUsers, "Users");
connUsers.Close();
} //try block
catch(Exception err)
{
log.WriteEntry("AccessDbMaster authentication failed. Info: " + err.Message);
retcode=-1;
ContextUtil.SetAbort();
}
I'm not out of the woods yet. Any advice will be greatly appreciated.
|
|
|
|
|
I believe it can
|
|
|
|
|
Humm... thanks... Need to trace that E_NOINTERFACE error, that makes me an unhappy man on this date November 12, 2003.
|
|
|
|
|
Hello,
I've a problem creating objects using Reflection. I tried to create a new System.Drawing.Size object using the CreateInstance Method from the Assembly class. Everything worked well, but if i try to cast this object into another Size object my application crashes.
Here is the source :
//----------------------------------------
using System;
using System.Drawing;
using System.Reflection;
namespace TestApp
{
public class TestApp
{
public static void Main ()
{
object[] args = new object[2];
args[0] = (int) 200;
args[1] = (int) 400;
object o1 = null;
object o2 = null;
Size s1 = new Size ();
try
{
o1 = CreateInstance ("System.Drawing.dll", "System.Drawing.Size", args);
}
catch (Exception ex)
{
Console.WriteLine (ex.Message);
}
try
{
o2 = new Size (200, 400);
}
catch (Exception ex)
{
Console.WriteLine (ex.Message);
}
try
{
Console.Write ("Trying to cast o2 to Size s1...");
s1 = (Size) o2;
Console.WriteLine ("DONE");
Console.WriteLine ("s1 : " + s1.ToString ());
Console.ReadLine ();
Console.Write ("Trying to cast o1 to Size s1...");
s1 = (Size) o1;
Console.WriteLine ("DONE");
Console.WriteLine ("s1 : " + s1.ToString ());
Console.ReadLine ();
}
catch (Exception ex)
{
Console.WriteLine (ex.Message);
Console.ReadLine ();
}
}
private static string GetSystemDir ()
{
Assembly [] assemblies = AppDomain.CurrentDomain.GetAssemblies ();
foreach (Assembly a in assemblies)
{
string codebase = a.CodeBase;
if (codebase.EndsWith ("corlib.dll"))
{
return codebase.Substring (0, codebase.LastIndexOf ("/")).Substring (8);
}
}
return "";
}
private static object CreateInstance (string AssemblyName, string ClassName, object[] args)
{
try
{
Assembly a = Assembly.LoadFile (GetSystemDir () + "/" + AssemblyName);
return a.CreateInstance (ClassName, true, BindingFlags.CreateInstance, null, args, null, null);
}
catch (Exception ex)
{
Console.WriteLine (ex.Message);
}
return null;
}
}
}
//----------------------------------------
I hope someone can help me. Thanx in advance
( Sorry about some mistakes, my english is not so good )
|
|
|
|
|
It's failing because your not loading the containing assembly correctly. If you read the documentation for Assembly.CreateInstance , it returns null if the type was not found. Since you're dealing with value types - which cannot be null - casting a null reference to a value type will throw an exception.
I think you're missing the point of the global assembly cache (GAC). You don't have to - nor should you - worry about where the assemblies are so long as they are in the GAC or the private path (the "bin" folder, for instance, in ASP.NET). .NET, first of all, does not use the %PATH% env var. If the Type you want to create is contained in an assembly in the GAC or the private path of your application, you simply create the Type and assembly - if not already loaded - is loaded from the GAC automatically (and if a pre-JIT'ed (native) assembly exists, it'll be used instead because it loads and executes faster).
Try this:
Type t = Type.GetType("System.Drawing.Size, System.Drawing", false, true);
Size s = (Size)t.Assembly.CreateInstance(t.ToString(), ...); Of course, there's many other ways to do this. The important thing is that you shouldn't worry about the paths to assemblies themselves unless they are your assembly in a non-private path, such as plugins or something. The .NET base class library (BCL) is in the GAC and should not be referenced by a local file path. Besides, the method you're using for finding the local path is extremely slow and inefficient. If nothing else, you should at least cache the directory once you've found it and avoid the large loop every time.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hello,
Thanks for you help. I've tried you code, but my app still does not work. If I try to get a System.Int32 or something else in the System assembly it works fine. But if I try to get a System.Drawing.Size it fails.
Type t1 = Type.GetType ("System.Reflection.Assembly", false, true);
Type t2 = Type.GetType ("System.Int32", false, true);
System.Drawing.Size s = new System.Drawing.Size (100, 200);
Type t3 = Type.GetType ("System.Drawing.Size, System.Drawing", true, true);
Type t4 = Type.GetType ("System.Drawing.Size", true, true);
What's my mistake ? I've included the link to the System.Drawing.dll in my project and I've also included a using System.Drawing; in my code. Is there any configuration to do for my app assembly ?
|
|
|
|
|
Stux wrote:
If I try to get a System.Int32 or something else in the System assembly it works fine.
Actually, those types are in the mscorlib.dll assembly, the implicit library that is always included.
Stux wrote:
What's my mistake ?
Good question. t3 is the correct code. Unless something is in the mscorlib.dll assembly (which is why I mentioned that above) or in the currently loaded assembly, you must give an assembly name like you did there. Everything looks right, though. Type.GetType will load the assembly in which the Type is contained if it isn't already. And you don't have to include a reference to it in your project if you plan on using Reflection. The BCL assemblies are in the GAC (at least they should be, open the folder \Windows\assembly and verify) which is alway checked after private paths (like the bin directory in ASP.NET) or assembly binding redirections in the .config file.
The only other thing I can think of that you could do is use the fully-qualified the type name, i.e. "System.Drawing.Size, System.Drawing, Culture=neutral, Version=1.0.3300.0, PublicKeyToken=b03f5f7f11d50a3a" (for .NET 1.0), although I've never had to do this on my work machine - but I only have one framework currently installed. Do you, by chance, have both .NET 1.0 and 1.1 installed?
Anyway, try using the FQN (fully-qualified name) and see if that works. Other than that, you're doing it right.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
You're right. I've both Frameworks installed, but I've already tested the fully-qualified type name. I've also tested the Project on an other machine, having only the .NET 1.1 Framework installed. Nothing worked
But I found an other solution :
Assembly a = Assembly.LoadWithPartialName ("System.Drawing");
Type t = a.GetType ("System.Drawing.Size");
I hope that will work until I've more time to examine the problem.
Thanks anyway.
Nice "Geek-Code-Block" I think I will also include one in my Profile.
|
|
|
|
|
Please help me ! I want to communicate bettwen a service and an application . But i don't know how to .
q
|
|
|
|
|