Custom class in DotNetNuke Module - vb.net

I know this can be done as there are other modules out there that have this, but I'm just not getting it to work.
I have created a custom module for a DotNetNuke site. I want to be able to create a class object within the module to hold the information about that object. I can create the object and everything complies. But when I go to use the object in the code-behind it states that the object is not defined. I'm not really sure where to go from here.
This is the beginning of the View.ascx.vb :
Namespace Modules.VacationForms
Public MustInherit Class View
Inherits PortalModuleBase
This is the object class beginning:
Namespace Modules.VacationForms
Public MustInherit Class Vacation
I'm really not sure why this is not working. I did download another module code to compare and as far as I can tell everything is the same. Any help is appreciated.

Are you using a Web Site Project or a Web Application Project? The Web Application project will allow you to compile all of your code together (the only issue here might be the the Root Namespace setting in your project, but, assuming both classes are in the same project, that shouldn't be it). If you're in the Web Site project (e.g. developing directly in the DNN solution), then your code won't get compiled in the traditional sense, but will be on-demand compiled by DNN. It only does that for code behind files associated with requested controls/pages (e.g. your View.ascx.vb) and code files in the App_Code folder. I would guess that your hangup is that your Vacation class' code file isn't in the App_Code folder.

It looks you are not using the Web Application Project for module development. Easiest thing to do is install module development templates (from dotnetnuke.codeplex.com download starterkit package of your dnn version).
If your module is too simple and you don't want to do that, OR you don't want to install the templates in your pc, you can do following:
If you are using a vs version that is not using WAP by default, get the installation from web.
create a new folder for your dnn module in DesktopModules directory in root
add a new WAP project in that folder.
remove web.config from that folder, go to properties and point build output director to your dnn site's bin directory (../../bin will work most of the time)
Once you are done with that, all your code will start working as expected.
Good thing about this is, all your .vb and .ascx.vb files will be compiled in a single dll that you can distribute as a package easily.
Hope this helps

Related

frame.navigate to a page in different .dll

I have a Page class in a project A. I want to navigate to this page from my Universal windows project(say Project B) page. In UWP I am trying to achieve this using Frame.Navigate(typeof(Page_classA)), since NavigationService.Navigate(new Uri()) is obsolete in UWP.
But I get a Windows.UI.Xaml.Markup.XamlParseException in this case.
Is there any other way in UWP or metro Apps for navigating to a page in different assembly?
We can use Frame.Navigate(TypeName) method to navigate to a page in different assembly.
For example, we can create a Class Library(Universal Windows) named "ProjectA" and in this project add a new Page named "PageA". Then in this project's Properties page, check the "Generate library layout" option in the Build configuration.
In WinRT environment, the resources are no longer embedded in the assembly but are placed next to the dll as content. So we need to generate library layout so that we can reference the dll in other project conveniently.
After this, we can build the project and we will get following layout in "Debug" folder:
In ProjectA folder, it contains .xaml file and .xr.xml file:
When we get the library output files, we can copy them to anywhere and in the Universal Windows Project(Project B), we just need to add reference to the "ProjectA.dll" file. Visual Studio will automatically pick these files up and put them in the appx package when it builds the app.
And in Project B, we can use following code to navigate to PageA:
Frame.Navigate(typeof(ProjectA.PageA))
In your case, you get a Windows.UI.Xaml.Markup.XamlParseException, this may be that the .pri file is missing when you add the reference. Here is a similar case. So please check your library layout and make sure these resources are are placed next to the dll you referenced.

how to know which version of jar is my tomcat server using

Why I need to do this: In my application I have some JAR file for connecting to MYSQL DB, now I have to extend this API so that my application can communicate to MongoDB.To do this I have to make changes in existing JAR file.
I don't have the source code of the JAR files so I de-compiled it, used the code to implement the interfaces, now I am unable to make a JAR file because may be the de-compiler did not de-compile the classes properly in the first place. So I separately compiled the newly written classes, I want some of the new classes to overwrite the existing ones.
I know that tomcat looks for classes in the following order:
1. System class loader classes
2. /WEB-INF/classes of your web application
3. /WEB-INF/lib/*.jar of your web application
so I put new classes in /WEB-INF/classes/ directory.
My tomcat server is still not using the newly added classes, is there any way to know which class is my class loader using and how to make it load the newly added classes?

Reference VB.NET DLL in Kofax Document Validation Script

We are working on a validation script for Kofax Capture 9.0 / 10.0 in VB.NET 3.5.
We know how to create a script using the Admin Module, and how to get it operational.
The problem is that we need to reference a dll, located on a remote machine. (GAC is no option) This dll holds abstract classes we need in each validation script.
Even when putting the dlls locally (copy local), the Validation Module (index.exe) immediately throws the "cannot find reference" exception, even though the project compiled perfectly.
I guess the basic question comes down to: where do we put the dlls, in order for the Validation Module to find them?
The simple answer is to put the dll in the same folder as the application because this is one of the places which .NET will probe when trying to find it. The Validation module is run from the Capture bin directory which will be something like "C:\Program Files (x86)\Kofax\CaptureSS\ServLib\Bin\". This would need to be done on each client using Validation.
If you have a more complicated scenario, you could look implementing the AppDomain.AssemblyResolve Event and using Assembly.LoadFile to get the assembly from a custom location, but the using the bin path is less complicated.
If you end up having further trouble, you can troubleshoot by using the Assembly Binding Log Viewer (Fuslogvw.exe) which can tell you more details about why the assembly failed to load and where .NET tried to search for it. Assembly loading can fail for reasons other than just the path.
For more detail on how .NET loads assemblies, see the following:
How the Runtime Locates Assemblies
Locating the Assembly through Codebases or Probing
We found a solution: add all library files as "links" to the project. (Add --> Existing File --> small arrow next to "Add" --> Add as Link)
This ensures the files are compiled when you build the project. The Kofax Validation Module can now find the files, whereas when referencing the file, it could not. Why it could not, remains a mystery...

App_Code folder created automatically in published website

I have a MVC4 App created in VS 2010 with Umbraco 6 too and I've created a web deploy project which is used by my Team City CI server to deploy my website to a CI environment for testing.
On the CI server the first time I load the homepage (or any page) it loads perfectly fine. However the act of loading a page creates a App_Code folder on my CI server, and after that I get the message "The directory '/App_Code/' is not allowed because the application is precompiled". Removing the App_Code folder means that it once again works for one page load and the folder is created again.
Removing the PrecompiledApp.config file causes my site to not load with a YSOD stating "Object reference not set to an instance of an object." at the following point in the stack trace "Umbraco.Web.UmbracoModule.BeginRequest(HttpContextBase httpContext) +25"
To be clear, I don't have an App_Code folder in my project, and I don't want or need one. All I want is for it to stop creating one automatically upon page load! I've used Umbraco in VS and deployed in the same way many times before, just not with Umbraco 6 and in an MVC project.
Any ideas why App_Code is being automatically created and what I can do to stop it?
Many Thanks
Richard
I seem to use Umbraco in a similar way as you do, wrapping it as a MVC 4 project. Hence it becomes a "VS Web Application" instead of a "VS Web Site".
What is important to remember is that Umbraco originally wasn't made to be run as an application and a lot of the functionality in Umbraco is first and foremost directed to using App_Code.
The internal classes AssemblyExtensions, PluginManager, TypeHelper and the public class TypeFinder in Umbraco.Core have methods that are dependent on that the App_Code folder is there. Even if you don't need an App_Code in your solution Umbraco does, if you don't want to see it simply hide it from your solution. If you really don't want it remove all references to it in the source and create your own compilation of Umbraco.
== EDIT BELOW ==
After reading your comment and post again I created a small solution for your problem. The fact that Umbraco creates the App_Code is still because of the framework initialization that won't work without App_Code existing. But recompiling and creating an own dist of Umbraco will as OP points out create some extra maintenance when upgrading and so on.
It's not the ideal but most clean way to handle this matter to allow Umbraco to create the App_Code folder but also remove the same when the application have initialized. I'd use an IApplicationEventHandler. The sample code works on my box.
using Umbraco.Core;
using Umbraco.Core.IO;
namespace YourNamespace.EventHandlers
{
public class AppCodeEvents : IApplicationEventHandler
{
public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{ }
public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{ }
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
if (System.IO.Directory.Exists(IOHelper.MapPath(IOHelper.ResolveUrl("~/App_Code"))))
{
System.IO.Directory.Delete(IOHelper.MapPath(IOHelper.ResolveUrl("~/App_Code")));
}
}
}
}
If you are precompiling your site using a web deploy project, I assume you have all your references separated out from the project - which is a good thing. So, I think the simple answer here is don't precompile the site, just allow the web application to be built so that it pulls in the references and deploy the built project.
Personally, I find the best way to work with Umbraco v6 is via NuGet. Create an empty MVC4 project and use NuGet to add Umbraco v6. This will automatically sort out all the references for you. This is because those fantastic guys at Umbraco created two Nuget packages, one with the project files and the other with the core DLLs.
This means that when the site is built, the references are pulled in and updating the site is easy. It is just a matter of updating via NuGet.
This was happening me as well, turned out it was because a 'precompiledApp.config' file had somehow made its way onto the production server... not sure how that happened but once I deleted and recycled web app this stopped happening.

Why is rubygem's "lib" directory not called "src"?

I've never had any problem with the basic gem tree structure, namely
bin (executables)
lib (source code)
test
...because I've always developed gems as libraries. However, I recently started to develop an application that ships as a gem.
This application has a "runner.rb" file (lib/mygem/runner.rb), that provides a method to run the application. The application is run from the bin/mygem file.
Now this bothers me. "runner.rb" is a file that is specific to our application, it is not a service or an API or any kind of support class for other to reuse (which is what library should be for, right?), yet its directory is "lib/mygem/runner.rb).
I've been reading a lot of definitions, and libraries are supposed to be support an application, not to be the application itself. We don't say "this is the library of my application", but "this is the source code of my application".
So my question is, why do we put the libraries AND source code in the same folder?
I hope I made my point clear, I'm sure there's a good reason behind this, and I'd be interested to hear your thought and to clear this out.
Thank you for reading this :)
After even further investigations, it turns out 'lib/' is called 'lib/' because it only contains definitions.
'bin' is a script that gets executed, like a 'main' function. Since it gets executed, no application logic should be in it, otherwise it's not easily testable.
Thus, all the application logic belongs to your application's library folder. The bin (main) file's only task is to instantiate your application's runner class and run it.