473,772 Members | 2,564 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why do I need to check the version myself?

Hi,

I got bit by the fact that applications using library files that are NOT
strongly named will use older versions of the library without generating an
error, so........

Is there a way to tell an application "Use the library files you were built
with or NEWER versions" without using the GAC?

I have tried giving my library files strong names, but that locks them to
ONE version of the library file. I know that you can add lines to your
application configuration file to tell the application to use a specific
version of a new file (i.e. if you using version 1.2.0.0- 1.2.3.0 now use
1.2.4.0). However, it doesn't allow me to specifiy "USE ALL newer versions"
(e.g. if you using version 1.2.0.0- 1.2.3.0 now use 1.2.*). I have to target
ONE newer version, which means EVERY time I have an update, I would have to
update every applications configuration file with new routing information.

I can use this code at runtime to fix the problem, but I'm look for other
options:

public static bool IsOkToUseLibrar ies(string sDirectory, string
sLibStartsWith,
Assembly asm, out string sProblem)
{
string sFileName;
sProblem = string.Empty;

foreach (AssemblyName asname in asm.GetReferenc edAssemblies())
{
if (asname.Name.St artsWith(sLibSt artsWith))
{
sFileName = sDirectory + "\\" + asname.Name + ".dll";
if (System.IO.File .Exists(sFileNa me))
{
System.Diagnost ics.FileVersion Info fvi =
System.Diagnost ics.FileVersion Info.GetVersion Info(sFileName) ;

// major.minor[.build[.revision]]
if ((fvi.FileMajor Part != asname.Version. Major))
{
sProblem = string.Format(" {0}.dll -> System {1} file " +
"found by a system {2} application.\n" , asname.Name,
fvi.FileMajorPa rt, asname.Version. Major);
}
else if ((fvi.FileMinor Part < asname.Version. Minor) ||
(fvi.FileBuildP art < asname.Version. Build) ||
(fvi.FilePrivat ePart < asname.Version. Revision))
{
sProblem = string.Format(" {0}.dll -> Expecting a " +
"version number greater than or equal to {1}, but found
{2}.\n",
asname.Name, asname.Version. ToString(), fvi.FileVersion );
}
}
}
}

return (sProblem == string.Empty);
}
Thanks for any suggestions,
Dave
Apr 10 '06 #1
6 2224
The behavior you describe is by design. The reason the app will use
the old version of the library is because the newer version's behavior
may not be compatiable with the older version. This is the cause of
many problems in the COM base world.

That said, you can specify using the application configuration file to
use newever versions of assemblies. Look up the bindingRedirect method
of the configuration file, that will give you information to force a
newer version of the library. Of course you would only want to do this
after you've tested your application against the newer version of the
library.

HTH
Andy

Apr 10 '06 #2
Andy,

Thanks for your response. I have looked at the bindingRedirect , but I would
have to modify the application configuration file of at least four different
application every time that I updated a library file because I can't specify
"use ALL newer files than the one you were compiled with".

Do you know if there is a way to do this in the configuration file without
naming the newer version number directly (i.e. 2.4.*)?

Dave
Apr 10 '06 #3
Dave,

I found somewhere that keeping the AssemblyVersion the same, but
changing the AssemblyFileVer sion would work. Not sure if that would be
useful to you however.

Does using a wildcard in the newVersion attribute work?

Andy

Apr 10 '06 #4
> Does using a wildcard in the newVersion attribute work?

I've tried it, but it doesn't work. You can specify a range for the old
version, but you have to specifically target the new version. Like:

<runtime>
<assemblyBindin g xmlns="urn:sche mas-microsoft-com:asm.v1">
<dependentAssem bly>
<assemblyIdenti ty name="mscorcfg"
publicKeyToken= "b03f5f7f11d50a 3a" culture="neutra l"/>
<bindingRedirec t
oldVersion="0.0 .0.0-65535.65535.655 35.65535" newVersion="1.0 .3300.0"/>
</dependentAssemb ly>
</assemblyBinding >
</runtime>

it would be nice if this worked:
<bindingRedirec t oldVersion="1.0 .0.0-1.3.2.65535" newVersion="1.3 .3.*"/>
or

<bindingRedirec t oldVersion="1.0 .0.0-1.3.65535.65535 " newVersion="1.4 .*"/>

Dave
Apr 11 '06 #5
> else if ((fvi.FileMinor Part < asname.Version. Minor) ||
(fvi.FileBuildP art < asname.Version. Build) ||
(fvi.FilePrivat ePart < asname.Version. Revision))


Should read:
else if ((fvi.FileMinor Part < asname.Version. Minor) &&
(fvi.FileBuildP art < asname.Version. Build) &&
(fvi.FilePrivat ePart < asname.Version. Revision))
Apr 11 '06 #6
I think you'll have to go the route of only changing the
AssemblyFileVer sion and keeping the value in AssemblyVersion the same.

Apr 11 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
7873
by: R.Wieser | last post by:
Hello All, I'm trying to get a "Virtual Listbox" to work. I've currently got a form, and used CreateWindowExA to create a ListBox with the LBS_OWNERDRAWFIXED and LBS_NODATA flags on it. I've allso subclassed the window and do see all kinds of WS_??? messages coming by. But now I'm stuck :-\ I've got *no* idea what to do next, and all my searching on the web leads me
7
1636
by: has | last post by:
<BLUSH> Careless talk costs lives, as they say. In my case, a throwaway comment that Python could trounce the notoriously underpowered and undersupported AppleScript language for "serious number crunching". (And Perl could beat Python, and Fortran could kick all their butts, etc...) Well, you'd think me and the other guy would be old enough to know better, or at least have more important things to do, but nooooo... Ah well, too late...
4
2761
by: kazack | last post by:
I posted a similiar question in this newsgroup already and got an answer which I already knew but didn't get the answer I was looking for so I am reposting the code and question differently in the hope that someone could help me out. As said in an earlier post I am new to c++, this is alot harder to do than VB. I am for the most part self taught with what I already know and looking to learn more. The book I am using to teach myself from...
55
3949
by: Alex | last post by:
Hello people, The following is not a troll but a serious request. I found myself in a position where I have to present a Pro/Con list to management and architects in our company with regard to developing new products (specifically - desktop products) in C#/.NET instead of the usual C++/COM that we do. Since I am not an experienced .NET developer by any definition, I don't have a good grip on the "Pro" part. The argument that I hear...
3
1950
by: TK | last post by:
Excuse me for multiple posting because I've posted this message to aspnet.security NG but have not got any response yet. I'm building an ASP.NET application works in Forms Authentication mode with custom user account database. And it shows clients a list of hyperlinks to content pages located in some separated subfolders. This application and content pages are entirely secured, so everyone must logon to the application. The application...
15
4642
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to communicate with a MySQL database table on a web server, from inside of my company's Access-VBA application. I know VBA pretty well but have never before needed to do this HTTP/XML/MySQL type functions.
4
2760
by: georges the man | last post by:
hey guys, i ve been posting for the last week trying to understand some stuff about c and reading but unfortunaly i couldnt do this. i have to write the following code. this will be the last time i ask for an entire code or u can give me the outine of what to do and i ll do it by myself. the description is the following: the program will read a text file that contains historical price of a stock. The program will allow users to query...
1
1028
by: GS | last post by:
I am still a novice in vb .net 2. actually in vb.net period. please bear with me. Problem: I often found myself refereeing to common utility like setStatus and logs on the form, and the application title in some messages. Question. how should I best avoid that ? my kludge is using fully qualified name My.Forms.myformname.whatever
6
2913
by: Pavel | last post by:
Hello, Does anyone know a (preferably open-source) multi-platform C or C++ library that would be able to write and read C/C++ doubles and floats to/from streambuf, char array or similar device in IEEE 754 with reasonably optimal precision and performance? The purpose is to exchange serialized doubles and floats between C/C++ and Java programs where Java serialization rules are used.
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10264
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8937
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4009
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.