andrewdavey / postal

Email sending for asp.net mvc using the view engine system to render emails.
http://aboutcode.net/postal
MIT License
536 stars 168 forks source link

provide alternative packages for mvc4 #43

Closed davidlaym closed 10 years ago

davidlaym commented 12 years ago

postal has a hard reference on mvc3 (assembly references) which makes impossible to add filesystemrazorengie or resourcerazorviewEngine in a aspnet mvc 4 app.

My specific use case is i'm running a light background job in a mvc4 app (using web-backgrounder) that sends emails with a resourcerazorviewEngine, but failing given that the ViewEngineCollection checks that ResourceRazorViewEngine inherits from IViewEngine from asp.net.mvc 4.0.0.0 which is not.

I propose to make a postal.core (no references to mvc) and postal.mvc3 + postal.mvc4

andrewdavey commented 11 years ago

Can you try adding binding redirects to your web.config?

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers"
             publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc"
             publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="4.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages"
             publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
vkornov commented 11 years ago

Hey, just so you know I've just wasted an hour of my life trying to fix a "must derive from WebViewPage error" in a MVC 4.0 project. Apparently, it checks for MVC 3.0 version of the class. Added the binding redirects, the issue went away.

andrewdavey commented 10 years ago

Postal v0.9.0 references MVC with SpecificVersion=False set. So that should alleviate issues like this.