The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

import-bot (20211) [Avatar] Offline
#1
[Originally posted by hwayoungko]

I tested this example..

using System;
using System.Reflection;

[assembly:AssemblyKeyFile(@"..key.snk")]
[assembly:AssemblyVersion("1.0.0.0")]

public class Person {
public Person(string firstName, string lastName, int age) {
AssemblyName aName=GetType().Assembly.GetName();
Console.WriteLine("-------------------------------");
Console.WriteLine("name : {0}",aName.Name);
Console.WriteLine("Version : {0}",aName.Version);
Console.WriteLine("-------------------------------");
FirstName=firstName;
LastName=lastName;
Age=age;
}
public readonly string FirstName;
public readonly string LastName;
public readonly int Age;
}

and I succeeded till registering 2 assemblies to winnt/assembly ...

when I was excuting this command ,, people...it hadn't been changed to 2.0.0.0.

I made person1000 and person2000 under inetpub/wwwroot/ .

this'd be problem?

and

<configuration>
<startup>
<requiredRuntime safeMode="true" version="v1.0.3705"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.vl">
<dependentAssembly>
<assemblyIdentity name="person">
publicKeyToken="2045efc24ac5d19e"
culture=""/>
<bindingRedirect oldVersion="1.0.0.0">
newVersion="2.0.0.0"/>
</dependentAssembly>
</assebmlyBinding>
</runtime>
</configuration>

in this coding,
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.vl">

Now I'm thinking, here might have caused problem not to working properly.

every machine definitely has asm.vl file? or else, my machine didn't got this

file, so in my case, my machine can't understand this type of xml file?

I did everything according to the book. filename is people.exe.config and

it's located on the same directory with people.exe. but result is always

1.0.0.0 . It never changed 2.0.0.0.

Please help me.



Hwayoung.
import-bot (20211) [Avatar] Offline
#2
Re: person.exe.config
[Originally posted by fgrimes]

Hi Hwayoung,

I set this example up once again to see if something had changed, but it
worked fine. Therefore I can only suggest that you carefully retrace the
steps presented in section 2.6. As you do this, try the following:

1. Move the files out of inetpub/wwwroot/. (No good reason, just one less
complication.)
2. Make sure to create separate subdirecories for v1.0.0.0 and v2.0.0.0 of
person.dll
3. Compile both DLLs from parent directory:
CsmilieotNetcha_2>csc /target:library /out:person1000person.dll
person1000person.cs
CsmilieotNetcha_2>csc /target:library /out:person2000person.dll
person2000person.cs
4. Execute gacutil from parent directory for both DLLs as shown in fig 2.9.
5. Compile people:
csc /r:person1000/person.dll people.cs

You can use the following simpler config file:

<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="person" publicKeyToken="xxxxxxxxxxxxxxxx" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

Just remember to insert the correct publicKeyToken generated by gacutil.
Explore C:WINNTAssembly to find the correct value.

Let me know what happens.

Regards,
Fergal
import-bot (20211) [Avatar] Offline
#3
Re: person.exe.config
[Originally posted by dennisjmurphy]

I've just fixed the problem described here myself. The publicKeyToken value in
the people.exe.config file MUST match the Public Key token for the assemblies
you created. Check the token in the global assembly cache and use that value
in the config file.

Dennis Murphy