The documentation (here and here) is notably lacking information on how references in modules are resolved:
References Resolution
(TODO: Explain how Orchard figures out references by looking at the "References" section of the csproj file as well as looking at additional assembly binaries dropped in each module "bin" directory)
Unfortunately, this is exactly the information that I need. I have created a custom module that has a reference to a custom-built, in-house DLL. When I try to use a class from this DLL, I get the following Exception:
Could not load type 'Custom.MyClass' from assembly 'Custom, Version=[version], Culture=[culture], PublicKeyToken=[token]'.
So, my question is thus: What does Orchard do with module references, and is there anything special I need to do to have Orchard pick up my module's references?
EDIT: Looks like some better information can be found in this blog post and its comments. However, my custom assembly already exists in src\Orchard.Web\App_Data\Dependencies, and I'm still getting the error.
EDIT2: We have a copy of the custom DLL in the lib folder, so I tried referencing that one instead (as we have another module that does so successfully), but still no change.
EDIT3:: In reference to the previous two edits, it's not copying from the lib folder to the App_Data\Dependencies folder. I just added a new DLL to the lib folder and referenced it, and it didn't appear in the Dependencies folder. I think the current Custom.dll isn't replacing the one that's there, which is why I'm getting the error I am. But why isn't Orchard copying into the Dependencies folder?
In order to have Orchard to use your custom module you need to have it on path: your_web_application_path/Modules/your_custom_module, we are using sym links to achieve that.
Then your main module (web application) should see your custom module. If you are adding new module to existing orchard app, you probably need to enable it by hand from admin panel/modules menu. For new installations you could add feature enable directive to your recipe and add dependency to main module.txt file (assuming you want your module always on).
Another trouble shooting tips:
make sure your module build path is set to bin/ folder (not some bin/debug etc.)
make sure your module is really an orchard module (have module.txt file) and is seen in admin panel/modules
make sure it is enabled, new modules are by default disabled
make sure referenced libraries are referenced from static folder I mean not from someting like bin which is clean up during rebuild
Related
I'm coming from the Visual Studio world of solutions, where each solution can consist of multiple projects that can refer to each other.
What I want to do is create a modular Android project in Android Studio such that all my code doesn't live in one huge app project. However, it seems terribly difficult to do this, so much so that I am sure I am doing something wrong.
I created a blank project called MyProject. This creates a project with the name MyProject and a package com.sohum.myproject. There is a single app project contained within containing no source files.
I now want to add another module under the same namespace (e.g. com.sohum.myproject.library1). However, it seems when I try to add a new module via the menu, I can only do so into a com.sohum.library1 project. How do I get it to use the same package as the project?
My end goal is to have all my modules under the com.sohum.myproject package, referencing each other. For example:
com.sohum.myproject.application will be the entry point. It might depend on com.sohum.myproject.library1 and com.sohum.myproject.someotherlibrary. And I would like to see all of these modules when I open the MyProject file.
You can click File > New > New Module. Then choose Android Library and enter the details.
Reference: https://developer.android.com/studio/projects/android-library
Another way is to set up the project in a subpackage when creating it.
For example, create a project MyProject in a root directory. Call the application Application and rename the package to be com.sohum.myproject.app instead of just com.sohum.myproject. Now any new modules created will be added below the com.sohum.myproject package space.
This is possibly the dumbest question ever, but I've downloaded the jsPDF library from here: jsPDF. It's not offered through the NuGet packages, so how do I then use it in my .NET MVC project solution? Do I need to move the downloaded folder to the "Packages" folder in my project's directory? Do something else?
Obviously, I'm a total newbie to this, so please keep your answers uncomplicated if possible. Thanks!
A Nuget package is literally just a zip file of a compiled project. If it's C# code, it's a collection of DLLs, but depending on the project, it could have static resources like CSS, JS, etc. It could also have views or other resources. The long and short, is that all of this is just pretty much dumped into your project when you include a Nuget package, much as if you had simply added it yourself.
The slight exception is with DLLs, which are placed in packages simply to keep them organized, and then simply referenced by the project they were added to. Therefore, in order to add something not available as a Nuget, you simply just add all the stuff to your project. If there's JS/CSS and such, then just drop that somewhere in your project. If there's DLLs, create some place to house those on your filesystem, and then add a reference to them in your project. I would not recommend sticking them in the packages directory, because that's managed by Nuget, and it could clobber your DLLs if you put them there.
when creating a new module with
package create
it creates it using source code *.cs files, so as a result nuget package does not contain binaries, the source only
Is it any parameter or option to precompile module, so instead of source files, it will precompile DLL?
The only option I found, is to open package file (which is ZIP file) and update content manually, but this is not best solution
By design, Orchard modules are source code, to ensure that they are friendly to modification. If you want to deploy something without source code, it should be the whole site, not just one module. This can be done by building precompiled.
I have an existing solution (multiple projects, one MVC web project) that I'm trying to wrap into an Orchard module.
All documentation says that the web csproj should be at the root under my module directory (eg Modules/MyModule/MyWeb.csproj).
However, I have an existing solution structure where the sln file sits at the top level and each csproj file (and project content) sits in its own directory (the standard solution structure when you build a multi-project app in Visual Studio).
Is there a way I can tell my Module.txt file that the Orchard Module csproj is under MyModule/MyWeb/MyWeb.csproj? I'd prefer to not restructure the whole solution.
Thank you.
Note: As a point of clarification, it is not ~/Modules/MyModule/MyWeb.csproj but ~/Modules/MyModule/MyModule.csproj. The Folder name of the Module must match the file name of the project (before .csproj). This is enforced by the Dynamic Extension Loader, which requires ~/Module/{ModuleId}/{ModuleId}.csproj. (A similar approach is required for themes.)
The only potential way to do this is to write a custom module that follows the above that contains a custom loader. Within your module, create your own implementation of IExtensionLoader, and register it with Autofac. However, I don't know if it would work; I've never tried.
You will probably have an easier time reorganizing your solution.
I've made a hello world module for orchard following this tutorial http://docs.orchardproject.net/Documentation/Building-a-hello-world-module
I've opened up the csproj in VS2012 and changed the projecttype guids to be MVC https://stackoverflow.com/a/12811015/828859
When I build the module in MVC orchard uses the published DLL.
When i attempt to go to the /helloworld route i get 404 resource cannot be found
When i save a file and let the dynamic compilation in orchard do it's thing it works fine.
I would like to be able to deploy with a DLL so does anyone have any ideas on the problem?
Ok, two things.
First - you won't be able to deploy your module as a single DLL. There are lots of things that do not get compiled into the DLL, eg. the Module.txt manifest. It has to be there under /Modules/<YourModuleName> (as well as module's .csproj file, .cshtml files and some more). Otherwise, Orchard won't be able to find your module.
So the source code for the module has to be there, although if you build it and the module's DLL is in /Modules/<YourModuleName>/bin folder, dynamic compilation won't kick in.
Second - module development should be done using full source code - not with the downloaded deployment package. Please read here how to get full source code.