@@ -115,52 +115,52 @@ public static partial class FreeImage
115
115
116
116
#region General functions
117
117
118
- private const string FreeImageVersion = "3.17.0" ;
119
-
120
- /// <summary>
121
- /// Returns the internal version of this FreeImage .NET wrapper.
122
- /// </summary>
123
- /// <returns>The internal version of this FreeImage .NET wrapper.</returns>
124
- public static Version GetWrapperVersion ( )
125
- {
126
- if ( WrapperVersion == null )
127
- {
128
- lock ( WrapperVersionLock )
129
- {
130
- if ( WrapperVersion == null )
131
- {
132
- Assembly assembly = GetFreeImageAssembly ( ) ;
133
- AssemblyInformationalVersionAttribute attribute = assembly . GetCustomAttribute < AssemblyInformationalVersionAttribute > ( ) ;
134
-
135
- if ( attribute == null )
136
- {
137
- throw new InvalidOperationException ( "Failed to get assembly version attribute" ) ;
138
- }
139
-
140
- if ( string . IsNullOrWhiteSpace ( attribute . InformationalVersion ) )
141
- {
142
- throw new InvalidOperationException ( "No assembly version present" ) ;
143
- }
144
-
145
- string version = attribute . InformationalVersion ;
146
-
147
- string [ ] versionParts = version . Split ( new [ ] { '-' } , StringSplitOptions . RemoveEmptyEntries ) ;
148
-
149
- if ( versionParts . Length < 1 )
150
- {
151
- throw new InvalidOperationException ( "Invalid assembly version" ) ;
152
- }
153
-
154
- if ( false == Version . TryParse ( versionParts [ 0 ] , out WrapperVersion ) )
155
- {
156
- throw new InvalidOperationException ( "Unable to parse assembly version" ) ;
157
- }
158
- }
159
- }
160
- }
161
-
162
- return WrapperVersion ;
163
- }
118
+ private static readonly Version ExpectedNativeFreeImageVersion = new Version ( "3.17.0" ) ;
119
+
120
+ // /// <summary>
121
+ // /// Returns the internal version of this FreeImage .NET wrapper.
122
+ // /// </summary>
123
+ // /// <returns>The internal version of this FreeImage .NET wrapper.</returns>
124
+ // public static Version GetWrapperVersion()
125
+ // {
126
+ // if (WrapperVersion == null)
127
+ // {
128
+ // lock (WrapperVersionLock)
129
+ // {
130
+ // if (WrapperVersion == null)
131
+ // {
132
+ // Assembly assembly = GetFreeImageAssembly();
133
+ // AssemblyInformationalVersionAttribute attribute = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
134
+ //
135
+ // if (attribute == null)
136
+ // {
137
+ // throw new InvalidOperationException("Failed to get assembly version attribute");
138
+ // }
139
+ //
140
+ // if (string.IsNullOrWhiteSpace(attribute.InformationalVersion))
141
+ // {
142
+ // throw new InvalidOperationException("No assembly version present");
143
+ // }
144
+ //
145
+ // string version = attribute.InformationalVersion;
146
+ //
147
+ // string[] versionParts = version.Split(new[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
148
+ //
149
+ // if (versionParts.Length < 1)
150
+ // {
151
+ // throw new InvalidOperationException("Invalid assembly version");
152
+ // }
153
+ //
154
+ // if (false == Version.TryParse(versionParts[0], out WrapperVersion))
155
+ // {
156
+ // throw new InvalidOperationException("Unable to parse assembly version");
157
+ // }
158
+ // }
159
+ // }
160
+ // }
161
+ //
162
+ // return WrapperVersion;
163
+ // }
164
164
165
165
internal static Assembly GetFreeImageAssembly ( )
166
166
{
@@ -185,36 +185,37 @@ public static Version GetNativeVersion()
185
185
return new Version ( GetVersion ( ) ) ;
186
186
}
187
187
188
- /// <summary>
189
- /// Validates that the FreeImage library is available on the system - throws an exception if not
190
- /// </summary>
191
- /// <remarks>
192
- /// The FreeImage.NET library is a wrapper for the native C++ library
193
- /// (FreeImage.dll ... dont mix ist up with this library FreeImageNet.dll).
194
- /// The native library <b>must</b> be either in the same folder as the program's
195
- /// executable or in a folder contained in the envirent variable <i>PATH</i>
196
- /// (for example %WINDIR%\System32).<para/>
197
- /// Further more must both libraries, including the program itself,
198
- /// be the same architecture (x86 or x64) and be a compatible version.
199
- /// </remarks>
200
- public static void ValidateAvailability ( )
201
- {
202
- try
203
- {
204
- Version nativeVersion = new Version ( GetVersion ( ) ) ;
205
- Version wrapperVersion = GetWrapperVersion ( ) ;
188
+ /// <summary>
189
+ /// Validates that the FreeImage library is available on the system - throws an exception if not
190
+ /// </summary>
191
+ /// <remarks>
192
+ /// The FreeImage.NET library is a wrapper for the native C++ library
193
+ /// (FreeImage.dll ... dont mix ist up with this library FreeImageNet.dll).
194
+ /// The native library <b>must</b> be either in the same folder as the program's
195
+ /// executable or in a folder contained in the envirent variable <i>PATH</i>
196
+ /// (for example %WINDIR%\System32).<para/>
197
+ /// Further more must both libraries, including the program itself,
198
+ /// be the same architecture (x86 or x64) and be a compatible version.
199
+ /// </remarks>
200
+ public static void ValidateAvailability ( )
201
+ {
202
+ try
203
+ {
204
+ Version nativeVersion = new Version ( GetVersion ( ) ) ;
205
+ // Version wrapperVersion = GetWrapperVersion();
206
206
207
- if ( false == ( ( nativeVersion . Major > wrapperVersion . Major ) ||
208
- ( ( nativeVersion . Major == wrapperVersion . Major ) && ( nativeVersion . Minor > wrapperVersion . Minor ) ) ||
209
- ( ( nativeVersion . Major == wrapperVersion . Major ) && ( nativeVersion . Minor == wrapperVersion . Minor ) && ( nativeVersion . Build >= wrapperVersion . Build ) ) ) )
210
- {
211
- throw new FreeImageException ( "FreeImage library version mismatch" ) ;
212
- }
213
- }
214
- catch ( DllNotFoundException e )
215
- {
216
- throw new FreeImageException ( "FreeImage library not found" , e ) ;
217
- }
207
+ //if (false == ((nativeVersion.Major > wrapperVersion.Major) ||
208
+ // ((nativeVersion.Major == wrapperVersion.Major) && (nativeVersion.Minor > wrapperVersion.Minor)) ||
209
+ // ((nativeVersion.Major == wrapperVersion.Major) && (nativeVersion.Minor == wrapperVersion.Minor) && (nativeVersion.Build >= wrapperVersion.Build))))
210
+ if ( nativeVersion != ExpectedNativeFreeImageVersion )
211
+ {
212
+ throw new FreeImageException ( "FreeImage library version mismatch" ) ;
213
+ }
214
+ }
215
+ catch ( DllNotFoundException e )
216
+ {
217
+ throw new FreeImageException ( "FreeImage library not found" , e ) ;
218
+ }
218
219
#if NET462 || NET461 || NET46 || NET452 || NET451 || NET45 || NET40 || NET35 || NET20
219
220
catch ( EntryPointNotFoundException e )
220
221
{
0 commit comments