2 // System.Reflection.Emit/AssemblyBuilder.cs
5 // Paolo Molaro (lupus@ximian.com)
7 // (C) 2001 Ximian, Inc. http://www.ximian.com
11 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 using System.Reflection;
35 using System.Resources;
37 using System.Security.Policy;
38 using System.Runtime.Serialization;
39 using System.Globalization;
40 using System.Runtime.CompilerServices;
41 using System.Collections;
42 using System.Runtime.InteropServices;
43 using System.Security;
44 using System.Security.Cryptography;
45 using System.Security.Permissions;
48 using Mono.Security.Cryptography;
50 namespace System.Reflection.Emit {
52 internal struct RefEmitPermissionSet {
53 public SecurityAction action;
56 public RefEmitPermissionSet (SecurityAction action, string pset) {
62 internal struct MonoResource {
65 public string filename;
66 public ResourceAttributes attrs;
70 internal struct MonoWin32Resource {
76 public MonoWin32Resource (int res_type, int res_id, int lang_id, byte[] data) {
77 this.res_type = res_type;
79 this.lang_id = lang_id;
86 [ClassInterfaceAttribute (ClassInterfaceType.None)]
87 [ComDefaultInterfaceAttribute (typeof (_AssemblyBuilder))]
89 public sealed class AssemblyBuilder : Assembly {
90 #region Sync with reflection.h
91 private IntPtr dynamic_assembly;
92 private MethodInfo entry_point;
93 private ModuleBuilder[] modules;
96 private CustomAttributeBuilder[] cattrs;
97 private MonoResource[] resources;
103 PEFileKinds pekind = PEFileKinds.Dll;
106 Module[] loaded_modules;
107 MonoWin32Resource[] win32_resources;
108 private RefEmitPermissionSet[] permissions_minimum;
109 private RefEmitPermissionSet[] permissions_optional;
110 private RefEmitPermissionSet[] permissions_refused;
111 PortableExecutableKinds peKind;
112 ImageFileMachine machine;
113 bool corlib_internal;
115 internal Type corlib_object_type = typeof (System.Object);
116 internal Type corlib_value_type = typeof (System.ValueType);
117 internal Type corlib_enum_type = typeof (System.Enum);
118 internal Type corlib_void_type = typeof (void);
119 ArrayList resource_writers = null;
120 Win32VersionResource version_res;
123 private Mono.Security.StrongName sn;
125 [MethodImplAttribute(MethodImplOptions.InternalCall)]
126 private static extern void basic_init (AssemblyBuilder ab);
128 internal AssemblyBuilder (AssemblyName n, string directory, AssemblyBuilderAccess access, bool corlib_internal)
131 this.access = (uint)access;
133 // don't call GetCurrentDirectory for Run-only builders (CAS may not like that)
134 if (IsSave && (directory == null || directory == String.Empty)) {
135 dir = Directory.GetCurrentDirectory ();
140 /* Set defaults from n */
141 if (n.CultureInfo != null) {
142 culture = n.CultureInfo.Name;
144 Version v = n.Version;
146 version = v.ToString ();
149 if (n.KeyPair != null) {
150 // full keypair is available (for signing)
151 sn = n.KeyPair.StrongName ();
154 // public key is available (for delay-signing)
155 byte[] pk = n.GetPublicKey ();
156 if ((pk != null) && (pk.Length > 0)) {
157 sn = new Mono.Security.StrongName (pk);
161 this.corlib_internal = corlib_internal;
166 public override string CodeBase {
168 throw not_supported ();
172 public override MethodInfo EntryPoint {
178 public override string Location {
180 throw not_supported ();
185 /* This is to keep signature compatibility with MS.NET */
186 public override string ImageRuntimeVersion {
188 return base.ImageRuntimeVersion;
193 public void AddResourceFile (string name, string fileName)
195 AddResourceFile (name, fileName, ResourceAttributes.Public);
198 public void AddResourceFile (string name, string fileName, ResourceAttributes attribute)
200 AddResourceFile (name, fileName, attribute, true);
203 private void AddResourceFile (string name, string fileName, ResourceAttributes attribute, bool fileNeedsToExists)
205 check_name_and_filename (name, fileName, fileNeedsToExists);
207 // Resource files are created/searched under the assembly storage
210 fileName = Path.Combine (dir, fileName);
212 if (resources != null) {
213 MonoResource[] new_r = new MonoResource [resources.Length + 1];
214 System.Array.Copy(resources, new_r, resources.Length);
217 resources = new MonoResource [1];
219 int p = resources.Length - 1;
220 resources [p].name = name;
221 resources [p].filename = fileName;
222 resources [p].attrs = attribute;
226 /// Don't change the method name and parameters order. It is used by mcs
228 internal void AddPermissionRequests (PermissionSet required, PermissionSet optional, PermissionSet refused)
231 throw new InvalidOperationException ("Assembly was already saved.");
233 // required for base Assembly class (so the permissions
234 // can be used even if the assembly isn't saved to disk)
236 _optional = optional;
239 // required to reuse AddDeclarativeSecurity support
240 // already present in the runtime
241 if (required != null) {
242 permissions_minimum = new RefEmitPermissionSet [1];
243 permissions_minimum [0] = new RefEmitPermissionSet (
244 SecurityAction.RequestMinimum, required.ToXml ().ToString ());
246 if (optional != null) {
247 permissions_optional = new RefEmitPermissionSet [1];
248 permissions_optional [0] = new RefEmitPermissionSet (
249 SecurityAction.RequestOptional, optional.ToXml ().ToString ());
251 if (refused != null) {
252 permissions_refused = new RefEmitPermissionSet [1];
253 permissions_refused [0] = new RefEmitPermissionSet (
254 SecurityAction.RequestRefuse, refused.ToXml ().ToString ());
258 internal void EmbedResourceFile (string name, string fileName)
260 EmbedResourceFile (name, fileName, ResourceAttributes.Public);
263 internal void EmbedResourceFile (string name, string fileName, ResourceAttributes attribute)
265 if (resources != null) {
266 MonoResource[] new_r = new MonoResource [resources.Length + 1];
267 System.Array.Copy(resources, new_r, resources.Length);
270 resources = new MonoResource [1];
272 int p = resources.Length - 1;
273 resources [p].name = name;
274 resources [p].attrs = attribute;
276 FileStream s = new FileStream (fileName, FileMode.Open, FileAccess.Read);
278 resources [p].data = new byte [len];
279 s.Read (resources [p].data, 0, (int)len);
286 internal void EmbedResource (string name, byte[] blob, ResourceAttributes attribute)
288 if (resources != null) {
289 MonoResource[] new_r = new MonoResource [resources.Length + 1];
290 System.Array.Copy(resources, new_r, resources.Length);
293 resources = new MonoResource [1];
295 int p = resources.Length - 1;
296 resources [p].name = name;
297 resources [p].attrs = attribute;
298 resources [p].data = blob;
301 public ModuleBuilder DefineDynamicModule (string name)
303 return DefineDynamicModule (name, name, false, true);
306 public ModuleBuilder DefineDynamicModule (string name, bool emitSymbolInfo)
308 return DefineDynamicModule (name, name, emitSymbolInfo, true);
311 public ModuleBuilder DefineDynamicModule(string name, string fileName)
313 return DefineDynamicModule (name, fileName, false, false);
316 public ModuleBuilder DefineDynamicModule (string name, string fileName,
319 return DefineDynamicModule (name, fileName, emitSymbolInfo, false);
322 private ModuleBuilder DefineDynamicModule (string name, string fileName,
323 bool emitSymbolInfo, bool transient)
325 check_name_and_filename (name, fileName, false);
328 if (Path.GetExtension (fileName) == String.Empty)
329 throw new ArgumentException ("Module file name '" + fileName + "' must have file extension.");
331 throw new NotSupportedException ("Persistable modules are not supported in a dynamic assembly created with AssemblyBuilderAccess.Run");
333 throw new InvalidOperationException ("Assembly was already saved.");
336 ModuleBuilder r = new ModuleBuilder (this, name, fileName, emitSymbolInfo, transient);
338 if ((modules != null) && is_module_only)
339 throw new InvalidOperationException ("A module-only assembly can only contain one module.");
341 if (modules != null) {
342 ModuleBuilder[] new_modules = new ModuleBuilder [modules.Length + 1];
343 System.Array.Copy(modules, new_modules, modules.Length);
344 modules = new_modules;
346 modules = new ModuleBuilder [1];
348 modules [modules.Length - 1] = r;
352 [MethodImplAttribute(MethodImplOptions.InternalCall)]
353 private extern Module InternalAddModule (string fileName);
356 * Mono extension to support /addmodule in mcs.
358 internal Module AddModule (string fileName)
360 if (fileName == null)
361 throw new ArgumentNullException (fileName);
363 Module m = InternalAddModule (fileName);
365 if (loaded_modules != null) {
366 Module[] new_modules = new Module [loaded_modules.Length + 1];
367 System.Array.Copy (loaded_modules, new_modules, loaded_modules.Length);
368 loaded_modules = new_modules;
370 loaded_modules = new Module [1];
372 loaded_modules [loaded_modules.Length - 1] = m;
377 public IResourceWriter DefineResource (string name, string description, string fileName)
379 return DefineResource (name, description, fileName, ResourceAttributes.Public);
382 public IResourceWriter DefineResource (string name, string description,
383 string fileName, ResourceAttributes attribute)
385 IResourceWriter writer;
387 // description seems to be ignored
388 AddResourceFile (name, fileName, attribute, false);
389 writer = new ResourceWriter (fileName);
390 if (resource_writers == null)
391 resource_writers = new ArrayList ();
392 resource_writers.Add (writer);
396 private void AddUnmanagedResource (Win32Resource res) {
397 MemoryStream ms = new MemoryStream ();
400 if (win32_resources != null) {
401 MonoWin32Resource[] new_res = new MonoWin32Resource [win32_resources.Length + 1];
402 System.Array.Copy (win32_resources, new_res, win32_resources.Length);
403 win32_resources = new_res;
406 win32_resources = new MonoWin32Resource [1];
408 win32_resources [win32_resources.Length - 1] = new MonoWin32Resource (res.Type.Id, res.Name.Id, res.Language, ms.ToArray ());
412 public void DefineUnmanagedResource (byte[] resource)
414 if (resource == null)
415 throw new ArgumentNullException ("resource");
418 * The format of the argument byte array is not documented
419 * so this method is impossible to implement.
422 throw new NotImplementedException ();
425 public void DefineUnmanagedResource (string resourceFileName)
427 if (resourceFileName == null)
428 throw new ArgumentNullException ("resourceFileName");
429 if (resourceFileName == String.Empty)
430 throw new ArgumentException ("resourceFileName");
431 if (!File.Exists (resourceFileName) || Directory.Exists (resourceFileName))
432 throw new FileNotFoundException ("File '" + resourceFileName + "' does not exists or is a directory.");
434 using (FileStream fs = new FileStream (resourceFileName, FileMode.Open)) {
435 Win32ResFileReader reader = new Win32ResFileReader (fs);
437 foreach (Win32EncodedResource res in reader.ReadResources ()) {
438 if (res.Name.IsName || res.Type.IsName)
439 throw new InvalidOperationException ("resource files with named resources or non-default resource types are not supported.");
441 AddUnmanagedResource (res);
446 public void DefineVersionInfoResource ()
448 if (version_res != null)
449 throw new ArgumentException ("Native resource has already been defined.");
451 version_res = new Win32VersionResource (1, 0);
453 if (cattrs != null) {
454 foreach (CustomAttributeBuilder cb in cattrs) {
455 string attrname = cb.Ctor.ReflectedType.FullName;
457 if (attrname == "System.Reflection.AssemblyProductAttribute")
458 version_res.ProductName = cb.string_arg ();
459 else if (attrname == "System.Reflection.AssemblyCompanyAttribute")
460 version_res.CompanyName = cb.string_arg ();
461 else if (attrname == "System.Reflection.AssemblyCopyrightAttribute")
462 version_res.LegalCopyright = cb.string_arg ();
463 else if (attrname == "System.Reflection.AssemblyTrademarkAttribute")
464 version_res.LegalTrademarks = cb.string_arg ();
465 else if (attrname == "System.Reflection.AssemblyCultureAttribute")
466 version_res.FileLanguage = new CultureInfo (GetCultureString (cb.string_arg ())).LCID;
467 else if (attrname == "System.Reflection.AssemblyFileVersionAttribute")
468 version_res.FileVersion = cb.string_arg ();
469 else if (attrname == "System.Reflection.AssemblyInformationalVersionAttribute")
470 version_res.ProductVersion = cb.string_arg ();
471 else if (attrname == "System.Reflection.AssemblyTitleAttribute")
472 version_res.FileDescription = cb.string_arg ();
473 else if (attrname == "System.Reflection.AssemblyDescriptionAttribute")
474 version_res.Comments = cb.string_arg ();
479 public void DefineVersionInfoResource (string product, string productVersion,
480 string company, string copyright, string trademark)
482 if (version_res != null)
483 throw new ArgumentException ("Native resource has already been defined.");
486 * We can only create the resource later, when the file name and
487 * the binary version is known.
490 version_res = new Win32VersionResource (1, 0);
491 version_res.ProductName = product;
492 version_res.ProductVersion = productVersion;
493 version_res.CompanyName = company;
494 version_res.LegalCopyright = copyright;
495 version_res.LegalTrademarks = trademark;
499 * Mono extension to support /win32icon in mcs
501 internal void DefineIconResource (string iconFileName)
503 if (iconFileName == null)
504 throw new ArgumentNullException ("iconFileName");
505 if (iconFileName == String.Empty)
506 throw new ArgumentException ("iconFileName");
507 if (!File.Exists (iconFileName) || Directory.Exists (iconFileName))
508 throw new FileNotFoundException ("File '" + iconFileName + "' does not exists or is a directory.");
510 using (FileStream fs = new FileStream (iconFileName, FileMode.Open)) {
511 Win32IconFileReader reader = new Win32IconFileReader (fs);
513 ICONDIRENTRY[] entries = reader.ReadIcons ();
515 Win32IconResource[] icons = new Win32IconResource [entries.Length];
516 for (int i = 0; i < entries.Length; ++i) {
517 icons [i] = new Win32IconResource (i + 1, 0, entries [i]);
518 AddUnmanagedResource (icons [i]);
521 Win32GroupIconResource group = new Win32GroupIconResource (1, 0, icons);
522 AddUnmanagedResource (group);
526 private void DefineVersionInfoResourceImpl (string fileName) {
528 if (version_res.FileVersion == "0.0.0.0")
529 version_res.FileVersion = version;
530 version_res.InternalName = Path.GetFileNameWithoutExtension (fileName);
531 version_res.OriginalFilename = fileName;
533 AddUnmanagedResource (version_res);
536 public ModuleBuilder GetDynamicModule (string name)
539 throw new ArgumentNullException ("name");
541 throw new ArgumentException ("Name can't be null");
544 for (int i = 0; i < modules.Length; ++i)
545 if (modules [i].name == name)
550 public override Type[] GetExportedTypes ()
552 throw not_supported ();
555 public override FileStream GetFile (string name)
557 throw not_supported ();
560 public override FileStream[] GetFiles(bool getResourceModules) {
561 throw not_supported ();
564 public override ManifestResourceInfo GetManifestResourceInfo(string resourceName) {
565 throw not_supported ();
568 public override string[] GetManifestResourceNames() {
569 throw not_supported ();
572 public override Stream GetManifestResourceStream(string name) {
573 throw not_supported ();
575 public override Stream GetManifestResourceStream(Type type, string name) {
576 throw not_supported ();
579 internal bool IsSave {
581 return access != (uint)AssemblyBuilderAccess.Run;
585 internal string AssemblyDir {
592 * Mono extension. If this is set, the assembly can only contain one
593 * module, access should be Save, and the saved image will not contain an
596 internal bool IsModuleOnly {
598 return is_module_only;
601 is_module_only = value;
610 void Save (string assemblyFileName, PortableExecutableKinds portableExecutableKind, ImageFileMachine imageFileMachine)
612 this.peKind = portableExecutableKind;
613 this.machine = imageFileMachine;
615 if (resource_writers != null) {
616 foreach (IResourceWriter writer in resource_writers) {
622 // Create a main module if not already created
623 ModuleBuilder mainModule = null;
624 if (modules != null) {
625 foreach (ModuleBuilder module in modules)
626 if (module.FullyQualifiedName == assemblyFileName)
629 if (mainModule == null)
630 mainModule = DefineDynamicModule ("RefEmit_OnDiskManifestModule", assemblyFileName);
633 mainModule.IsMain = true;
636 * Create a new entry point if the one specified
637 * by the user is in another module.
639 if ((entry_point != null) && entry_point.DeclaringType.Module != mainModule) {
641 if (entry_point.GetParameters ().Length == 1)
642 paramTypes = new Type [] { typeof (string) };
644 paramTypes = new Type [0];
646 MethodBuilder mb = mainModule.DefineGlobalMethod ("__EntryPoint$", MethodAttributes.Static|MethodAttributes.PrivateScope, entry_point.ReturnType, paramTypes);
647 ILGenerator ilgen = mb.GetILGenerator ();
648 if (paramTypes.Length == 1)
649 ilgen.Emit (OpCodes.Ldarg_0);
650 ilgen.Emit (OpCodes.Tailcall);
651 ilgen.Emit (OpCodes.Call, entry_point);
652 ilgen.Emit (OpCodes.Ret);
657 if (version_res != null)
658 DefineVersionInfoResourceImpl (assemblyFileName);
661 // runtime needs to value to embed it into the assembly
662 public_key = sn.PublicKey;
665 foreach (ModuleBuilder module in modules)
666 if (module != mainModule)
669 // Write out the main module at the end, because it needs to
670 // contain the hash of the other modules
673 if ((sn != null) && (sn.CanSign)) {
674 sn.Sign (System.IO.Path.Combine (this.AssemblyDir, assemblyFileName));
680 public void Save (string assemblyFileName)
682 Save (assemblyFileName, PortableExecutableKinds.ILOnly, ImageFileMachine.I386);
685 public void SetEntryPoint (MethodInfo entryMethod)
687 SetEntryPoint (entryMethod, PEFileKinds.ConsoleApplication);
690 public void SetEntryPoint (MethodInfo entryMethod, PEFileKinds fileKind)
692 if (entryMethod == null)
693 throw new ArgumentNullException ("entryMethod");
694 if (entryMethod.DeclaringType.Assembly != this)
695 throw new InvalidOperationException ("Entry method is not defined in the same assembly.");
697 entry_point = entryMethod;
701 public void SetCustomAttribute( CustomAttributeBuilder customBuilder)
703 if (customBuilder == null)
704 throw new ArgumentNullException ("customBuilder");
706 string attrname = customBuilder.Ctor.ReflectedType.FullName;
710 if (attrname == "System.Reflection.AssemblyVersionAttribute") {
711 version = create_assembly_version (customBuilder.string_arg ());
713 } else if (attrname == "System.Reflection.AssemblyCultureAttribute") {
714 culture = GetCultureString (customBuilder.string_arg ());
715 } else if (attrname == "System.Reflection.AssemblyAlgorithmIdAttribute") {
716 data = customBuilder.Data;
718 algid = (uint)data [pos];
719 algid |= ((uint)data [pos + 1]) << 8;
720 algid |= ((uint)data [pos + 2]) << 16;
721 algid |= ((uint)data [pos + 3]) << 24;
722 } else if (attrname == "System.Reflection.AssemblyFlagsAttribute") {
723 data = customBuilder.Data;
725 flags = (uint)data [pos];
726 flags |= ((uint)data [pos + 1]) << 8;
727 flags |= ((uint)data [pos + 2]) << 16;
728 flags |= ((uint)data [pos + 3]) << 24;
732 if (cattrs != null) {
733 CustomAttributeBuilder[] new_array = new CustomAttributeBuilder [cattrs.Length + 1];
734 cattrs.CopyTo (new_array, 0);
735 new_array [cattrs.Length] = customBuilder;
738 cattrs = new CustomAttributeBuilder [1];
739 cattrs [0] = customBuilder;
746 public void SetCustomAttribute ( ConstructorInfo con, byte[] binaryAttribute) {
748 throw new ArgumentNullException ("con");
749 if (binaryAttribute == null)
750 throw new ArgumentNullException ("binaryAttribute");
752 SetCustomAttribute (new CustomAttributeBuilder (con, binaryAttribute));
755 internal void SetCorlibTypeBuilders (Type corlib_object_type, Type corlib_value_type, Type corlib_enum_type) {
756 this.corlib_object_type = corlib_object_type;
757 this.corlib_value_type = corlib_value_type;
758 this.corlib_enum_type = corlib_enum_type;
761 internal void SetCorlibTypeBuilders (Type corlib_object_type, Type corlib_value_type, Type corlib_enum_type, Type corlib_void_type)
763 SetCorlibTypeBuilders (corlib_object_type, corlib_value_type, corlib_enum_type);
764 this.corlib_void_type = corlib_void_type;
767 private Exception not_supported () {
768 // Strange message but this is what MS.NET prints...
769 return new NotSupportedException ("The invoked member is not supported in a dynamic module.");
772 private void check_name_and_filename (string name, string fileName,
773 bool fileNeedsToExists) {
775 throw new ArgumentNullException ("name");
776 if (fileName == null)
777 throw new ArgumentNullException ("fileName");
779 throw new ArgumentException ("name cannot be empty", "name");
781 throw new ArgumentException ("fileName cannot be empty", "fileName");
782 if (Path.GetFileName (fileName) != fileName)
783 throw new ArgumentException ("fileName '" + fileName + "' must not include a path.");
785 // Resource files are created/searched under the assembly storage
787 string fullFileName = fileName;
789 fullFileName = Path.Combine (dir, fileName);
791 if (fileNeedsToExists && !File.Exists (fullFileName))
792 throw new FileNotFoundException ("Could not find file '" + fileName + "'");
794 if (resources != null) {
795 for (int i = 0; i < resources.Length; ++i) {
796 if (resources [i].filename == fullFileName)
797 throw new ArgumentException ("Duplicate file name '" + fileName + "'");
798 if (resources [i].name == name)
799 throw new ArgumentException ("Duplicate name '" + name + "'");
803 if (modules != null) {
804 for (int i = 0; i < modules.Length; ++i) {
805 // Use fileName instead of fullFileName here
806 if (!modules [i].IsTransient () && (modules [i].FileName == fileName))
807 throw new ArgumentException ("Duplicate file name '" + fileName + "'");
808 if (modules [i].Name == name)
809 throw new ArgumentException ("Duplicate name '" + name + "'");
814 private String create_assembly_version (String version) {
815 String[] parts = version.Split ('.');
816 int[] ver = new int [4] { 0, 0, 0, 0 };
818 if ((parts.Length < 0) || (parts.Length > 4))
819 throw new ArgumentException ("The version specified '" + version + "' is invalid");
821 for (int i = 0; i < parts.Length; ++i) {
822 if (parts [i] == "*") {
823 DateTime now = DateTime.Now;
826 ver [2] = (now - new DateTime (2000, 1, 1)).Days;
827 if (parts.Length == 3)
828 ver [3] = (now.Second + (now.Minute * 60) + (now.Hour * 3600)) / 2;
832 ver [3] = (now.Second + (now.Minute * 60) + (now.Hour * 3600)) / 2;
834 throw new ArgumentException ("The version specified '" + version + "' is invalid");
838 ver [i] = Int32.Parse (parts [i]);
840 catch (FormatException) {
841 throw new ArgumentException ("The version specified '" + version + "' is invalid");
846 return ver [0] + "." + ver [1] + "." + ver [2] + "." + ver [3];
849 private string GetCultureString (string str)
851 return (str == "neutral" ? String.Empty : str);