Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Distributing Telerik RadControls with WPF Application
Message
De
03/10/2013 04:16:24
 
 
À
02/10/2013 11:49:13
Information générale
Forum:
ASP.NET
Catégorie:
Produits tierce partie
Versions des environnements
Environment:
C# 4.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01584543
Message ID:
01584714
Vues:
28
>>>>>>>>Hi,
>>>>>>>>
>>>>>>>>I've bought Telerik RadControls for use in a C# 4.0 WPF desktop application developed using VS 2010 and am struggling on understanding how to distribute it with my Mere Mortals .Net application. I have found a section on installing the Telerik controls in the MM.NET help file, but I think that is how to get them installed on the development machine, not how to install them on the client's machine. I have also found these instructions here
>>>>>>>>
>>>>>>>>http://www.telerik.com/help/wpf/protecting-telerik-radcontrols-assembly.html
>>>>>>>>
>>>>>>>>but I am not making sense of them. Has anyone done this before and can give a newbie a helping hand?
>>>>>>>>
>>>>>>>>This looks like it is telling me I need the source code of the controls and then I hav eto merge them into my project. Is there an easier way where I just distribute the actual control as a separate dll or whatever?
>>>>>>>
>>>>>>>A quick look at that link seems to show that you only need take that approach if you want to compile the Telerik stuff directly into your executable (i.e. same assembly)
>>>>>>>
>>>>>>>Elsewhere it seems to imply that you simply take the standard approach of referencing the relevant Telerik assemblies in your own assemblies (which presumably is what you have done anyway? ) - which comes down to just making sure those assemblies are present in the same folder as your exe on the production machine....
>>>>>>
>>>>>>Funny, I had just decided to see if copying the dlls over would work and that apparently works. Where did you see the reference to just making sure the assemblies are available?
>>>>>
>>>>>
>>>>>If you just copy the dll used for developing, then anyone can use it
>>>>>
>>>>>
>>>>>Looks like there are two options to protect their Intellectual Property
>>>>>
>>>>>(1) Add the dll as an embedded resource ( it won't be visible as a file)
>>>>>(2) Protect the dll with a passphrase and add the passphrase to your app.xaml - so only your app cas use the dll
>>>>>
>>>>>Easiest imo is to include all the dlls as embedded resources, you can even deflate them. That way you only have one exe to distribute
>>>>
>>>>Thanks. I found some instructions on how to embed a resource. I guess the only down side is that will make the exe much bigger?
>>>
>>>
>>>Yes, it makes the exe bigger - but
>>>(1) there's only one item to distribute/copy - you don't care/forget about the extra 10 dlls you need
>>>(2) If the size of the exe is a problem, you can deflate the dlls prior to embedding them. That will cut the size of the exe roughly in two
>>>Of course, when the assembly is needed, you have to inflate it
>>>
>>>ps: To test an exe with embedded assemblies - copy it to another location. If it finds the assemblies on disc (in the same folder) it will use those instead of the embedded
>>
>>I didn't know the last bit - which seems to defeat one of the reasons to embed in the first place ?
>>But, IIRC, it's possible to programmatically load the embedded assembly.....
>>
>>UPDATE: http://stackoverflow.com/questions/222655/embedding-assemblies-inside-another-assembly (second answer)
>
>
>Yes,
>
>I use this
>
>	static class Program
>	{
>		static void Main(string[] args)
>		{
>			AppDomain.CurrentDomain.AssemblyResolve += LoadAssemblyFromEmbeddedResource.OnResolveAssembly;
>
>			Console.WriteLine("3 % 7 = {0}", 3.Modulo(7));
>
>			Console.ReadLine();
>		}
>	}
>
>
>
>static class LoadAssemblyFromEmbeddedResource
>	{
>		private static Dictionary<string, Assembly> Assemblies = new Dictionary<string, Assembly>();
>		private static object Locker = new object();
>
>		internal static Assembly OnResolveAssembly(object sender, ResolveEventArgs args)
>		{
>			Assembly returnvalue = null;
>
>			lock (Locker)  // one at a time 
>			{
>				Assembly executingAssembly = Assembly.GetExecutingAssembly();
>				AssemblyName assemblyName = new AssemblyName(args.Name);
>
>				string path = assemblyName.Name + ".dll";
>
>				if (!assemblyName.CultureInfo.Equals(CultureInfo.InvariantCulture))
>					path = String.Format(@"{0}\{1}", assemblyName.CultureInfo, path);
>
>				//Console.WriteLine("Resolving {0}\tPath={1}", assemblyName.Name, path);
>
>
>				if (!Assemblies.TryGetValue(path, out returnvalue))
>				{
>					// not in dictionary, try to load
>					using (Stream deflated = executingAssembly.GetManifestResourceStream(path))
>					{
>						if (deflated != null)
>						{
>							using (Stream inflated = new MemoryStream())
>							{
>								using (DeflateStream inflator = new DeflateStream(deflated, CompressionMode.Decompress))
>								{
>									inflator.CopyTo(inflated);
>									inflated.Position = 0; // important for the Read() to start at zero
>
>									byte[] bytes = new byte[inflated.Length];
>									inflated.Read(bytes, 0, bytes.Length);
>
>
>									returnvalue = Assembly.Load(bytes);
>
>									// add to dictionary
>									Assemblies.Add(path, returnvalue);
>								}
>							}
>						}
>					}
>				}
>			}
>
>			return returnvalue;
>		}
>
>	}
>
Looks like a much more robust version. And the "Console.WriteLine("3 % 7 = {0}", 3.Modulo(7));" is obviously an essential bit :-}
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform