error CS1705 when invoking csc.exe at runtime to load a different version assembly


environment details

vs2012 ultimate 11.0.50727.1

iis 7.5

.net 4.5

visual c#

problem description

our product comprises of several asp.net user controls hosted inside dnn framework. under normal circumstances have custom utility convert these user controls server controls, package inside assembly , host inside dnn. works fine. trying host these user controls in manner can omit packaging step, @ least during development. save lot of time, enable direct source code modifications (.ascx , .ascx.cs) without re-packaging , allow vs debugging out of box. enable this, have placed .ascx , .ascx.cs files inside specific folder within our hosted web site. @ runtime, call control.loadcontrol(control virtual path) load these controls. @ point csc.exe comes picture. things failing. hence posting in c# forum.

c# compiler tries compile dynamically generated .cs files , fails following exception:

error cs1705: assembly 'xxxxxxxxx, version=1.0.0.0, culture=neutral, publickeytoken=xxxxxx uses 'assembly1, version=40, culture=neutral, publickeytoken=xxxxxx' has higher version referenced assembly ' assembly1, version=35, culture=neutral, publickeytoken=xxxxxxx'

‘assembly1’ compiled version 40 while compiler finds version 35 in application directory. expected. have version 35 in application bin folder. reason - version 35 meant used dnn , version 40 more general version. have come across number of posts suggestion use <assemblybinding> , <codebase> configuration elements. tried following section:

<runtime>

    <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1">

      <dependentassembly>

        <assemblyidentity name="'assembly1" publickeytoken=" xxxxxx " />

                <codebase version="35" href="'assembly1.dll" />

<codebase version="40" href="providers\'assembly1.dll" />

      </dependentassembly>

    </assemblybinding>

  </runtime>

placed in csc.exe.config, machine.config web.config. c# compiler not recognize configuration section @ all.

have tried load version 40 assembly assembly.load. load version 40 assembly in app domain without load context. not our cause since c# compiler not inside app domain. probes gac , application directory. same reason why appdomain.currentdomain.assemblyresolve not work.

assembly.loadfile(path.combine(appdomain.currentdomain.basedirectory, "providers\assembly1.dll"))

questions

  1. why csc.exe ignoring configuration section?
  2. is there way pass additional runtime parameters csc.exe such looks assemblies @ specific folders opposed ‘well known folders’?



Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'