gigi81 / sharpfastcgi

C# fastcgi protocol implementation plus shome usage examples. A good example on how to self-host your web application without the need of iis or mono.
MIT License
32 stars 15 forks source link

Monodevelop-NGINX-Sharpfastcgi #4

Closed devim closed 11 years ago

devim commented 11 years ago

I found interesting article and sharpfastcgi yesterday, on the google-quest for "how to run my pascal FCGI application under nginx in windows?"

I started using sharpfastcgi, and being a newbie in monodevelop and C#, I found some reference error in Fastcgi.Test for "FastCgi" and "Fastcgi.ASPnet"

Environment: Windows7 Prof., 64Bit, Monodevelop 3.0.4.7, sharpfastcgi, NGINX

What I did to compile successfully: 1 Compiled Fastcgi 2 Compiled Fascgi.AspNet after adding rereference to "Fastcgi.dll" in debug 3 compiled Fastcgi.Test asfter adding rereference to "Fastcgi.dll " & "FastCgi.AspNet.dll" in debug directory of respective folder.

Now running the test program and having following error : Can you help ? +--------- E:\app\Mono\sharpfastcgi\FastCgi.Test\bin\Debug>FastCgiTest.exe

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or ass embly 'FastCgi.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or o ne of its dependencies. The system cannot find the file specified. at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, Bool ean loadTypeFromPartialName, ObjectHandleOnStack type) at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, Boolean l oadTypeFromPartialName) at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) at System.Type.GetType(String typeName, Boolean throwOnError) at System.Web.Hosting.HostingEnvironment.CreateInstance(String assemblyQualif iedName) at System.Web.Hosting.HostingEnvironment.CreateInstance(String assemblyQualif iedName) at System.Web.Hosting.ApplicationManager.CreateInstanceInNewWorkerAppDomain(T ype type, String appId, VirtualPath virtualPath, String physicalPath) at System.Web.Hosting.ApplicationHost.CreateApplicationHost(Type hostType, St ring virtualDir, String physicalDir) at FastCgi.Test.Program.Main(String[] args) in e:\app\Mono\sharpfastcgi\FastC gi.Test\Program.cs:line 17 --------+

IM

gigi81 commented 11 years ago

This is a problem caused by monodevelop. The asp.net self-hosting needs to have a copy of all the binaries in a "bin" directory of the web application. In other words all the .dll and .exe files needs to be copied to a bin subfolder of the website. In your case: under E:\app\Mono\sharpfastcgi\FastCgi.Test\bin\Debug\root you need to create E:\app\Mono\sharpfastcgi\FastCgi.Test\bin\Debug\root\bin and copy FastCgi.dll Fastcgi.ASPnet.dll and Fastcgi.Test.exe into this folder. Run again and it should be fine.

This operation is setup on the FastCgi.Test.prj postbuild actions. So it's done automatically under visual studio. Unfortunately it is not understood by monodevelop. You can configure it if you want to do the same.

devim commented 11 years ago

Same problem remains, after doing the following: 1.a Moving FastCGI.dll, Fashcgi.ASPnet.dll and Fastcgi.Test.exe to \sharpfastcgi\FastCgi.Test\bin\Debug\root\bin 1.b run Fastcgi.Test.exe from comand prompt this resulted same error.

2.a Also tried to FastCGI.dll, Fashcgi.ASPnet.dll and Fastcgi.Test.exe \sharpfastcgi\FastCgi.Test\bin\Debug 2.b run Fastcgi.Test.exe from comand prompt this also resulted same error.

devim commented 11 years ago

Interestingly, the issue solved, when I performed both step 1.a and 2.a and 2.b (i.e. running from Fastcgi.Test.exe from \sharpfastcgi\FastCgi.Test\bin\Debug )

However I have to check, what other steps I performed, to make sure what is absolute basic implementation.

I will post the details shortly.

gigi81 commented 11 years ago

The point is that I sad "COPY" not "MOVE". Basically you need the same binaries deployed twice and run the FastCgi.Test.exe in the debug folder, NOT the one in the debug\root\bin folder.

devim commented 11 years ago

Thanks. You are correct that:

  1. Copy the binary & required DLL to "..\root\bin" folder. (e.g. FastCGI.dll, Fashcgi.ASPnet.dll and Fastcgi.Test.exe to \sharpfastcgi\FastCgi.Test\bin\Debug\root\bin )
  2. Run FastCgi.Test.exe from .\ (e.g. from \sharpfastcgi\FastCgi.Test\bin\Debug location)