Some problems with basic DotNetNuke localization methods - dotnetnuke

I'm writing a simple DNN module - using DNN 5.6.1 and currently just working direct in a VB.Net source file within the DesktopModules subfolder of a DNN website.
To localize an error message within the module, I'm trying to use:
Dim baseString As String = Localization.GetString("CoveringErrorMessage", Me.LocalResourceFile)
However, this is currently returning "Nothing". Even though Me.LocalResourceFile seems to point to the correct path - /DesktopModules/MyModule/App_LocalResources/MyModule - where MyModule.ascx.resx resides, and even though "CoveringErrorMessage" is defined.
I've also checked that I can definitely edit the resx files from the Admin Language editor.
Beyond this, I've also got a problem with AddModuleMessage() not showing any message - so I'm wondering if there's some obvious setup step I've missed.
All ideas appreciated - this is just one of those frustrating things at present.

It'll look for CoveringErrorMessage.Text rather than just CoveringErrorMessage. Where there's not a . it adds .Test to the resource key.

Related

Hiding the word "joomla" from a script in contact form

Whenever i create a contact form in my Joomla! 3.3.6, some script appears in the the page's HTML code that contains many words Joomla in it. I'd like to change those Joomla words and replace them with another words (i.e. Foo) for some security issue. I'd like to know whether or not i'm able to do so and how.
That script is:
<script>(function(){var strings={"JLIB_FORM_FIELD_INVALID":"\u0641\u06cc\u0644\u062f \u0646\u0627\u0645\u0639\u062a\u0628\u0631:&#160"};if(typeof Joomla=='undefined'){Joomla={};Joomla.JText=strings;}
else{Joomla.JText.load(strings);}})();</script>
I have no idea whether a plugin or an extension creates it or not.
Thank you
Regards
This script seems to be translating some text required for the form to use in its javascript, eg validation messages. It does this using a javascript version of JText, which is part of core Joomla. There is some info on how that works here. Weirdly, there seems to be little information in the official Joomla documentation about it.
The main JText function it is calling appears here: media/system/js/core.js
I'm sure it would be possible to write a plug-in to remove this script before the page is rendered and then to translate any untranslated text with your own scripts. However, I'm not sure I see any security benefit in doing this so it seems a waste of time.
Ultimately, someone sniffing a site for what it is built in is far more likely to see if core files exist by going direct to places like media/system/js/core.js, rather than to scan the code for the word "Joomla" - which would trigger a lot of false-positives (any site which just mentions Joomla) and negatives (any page which doesn't have a form on it). It also does not reveal the version of Joomla, which is the info a hacker would more likely be after.
I think you have to search for the script (i.e via Notepad++) in the whole directory. It must be a plugin for the contact form that has some inline script in it.
also do you use any special third party plugin or so? that might be the source of it.
PS: also i had some similar experience, i don't know exactly how i got rid of those words, but like you, i wanted to do that to hide the fact that i'm using joomla for security.
Its actually Joomla who add this, from the file: Joomlainstall/libraries/joomla/document/html/renderer/head.php
And load it globaly from:
Joomlainstall/libraries/cms/html/formbehavior.php
The developer ad that code by using the function, JText, for an example:
JText::_( 'COM_CONTACT_EMAIL_FORM' )
In my case it was the plugin ContactUs Form who add the javascript. If JText is not used, it is not loaded. If I disabled the plugin, the javascript was then not loaded. If you have that plugin enabled, my be try an other contact form?
For security reson it is bad programming by the developer off Joomla, for sure.

asp.net pages can use class library but site won't compile

I am using VS2012 Update 3 and have a solution containing three visual basic projects a class library, a conosole app, and an IIS website.
The website has a reference to the library project. The library compiles fine and automatically places the latest dll in the bin folder of the website.
This was all working without issue before this week.
My web pages are able to import and use the class library. I get proper intellisense and the pages browse or eventually browse showing they are using the library. This week sometimes I get a type not defined error with browsing but after waiting it works. But the compile is always a fail now.
When compiling sometimes the errors show in the error list then eventually disappear but at ALL times when building the errors show up in the output tab as:
SomeCodeBehindFile.aspx.vb(#,#) error BC30002: Type 'SomeTypeInMyLibrary' is not defined.
Error BC30002 - Type XXX is not defined did not help. I tried using fully qualified variable types versus using the import. I tried changing the identity on the app pool to Network Service which has read permission on the whole site.
I've also tried Visual Studio's build > Clean Solution and deleting all files from windows' framework Temporary ASP.NET Files.
The only thing I may have done to irritate VS would have been renaming one of my asp files and its class names/page directive attributes manually but I have done this before without issue. I got paranoid and deleted that file and re-added it also. I also have 3 pages complaining about types not being defined now.
Was really perplexed for awhile. It also got worse with the pages using the library permanently refusing to browse. Though if I copied the library and erroring pages in another web app it would work! Not knowing what went off the rails I started a fresh VB web site and was back in business for awhile but then it started again. I did not connect what I did that actually caused the grief in my 2nd site. For a 3rd time I started a fresh web site this time using C#. Going great again up until that point I kept shooting myself. Thankfully the C# compiler gave a more helpful error message: "A using namespace directive can only be applied to namespaces; 'StaffPlusLibrary' is a type not a namespace". Grrr the problem was I kept adding a help page to the site related to the class library and called the page StaffPlusLibrary.aspx. I am careful not to name pages the same as existing classes but it did not register in my mind I was about to create a page using the same name as my library's root namespace. So the page created a class using the same name as the namespace. The ambiguity I introduced was not apparent until C#.

Why do I keep getting 'Assembly must be specified for XAML files that are not part of a project' errors in a local project?

To start with, I would like to stress that I do know how to define XML Namespaces correctly in my XAML files. This repeated error is not caused by an mistake in my code. The problem does not stop my project from being built successfully, or running and the mentioned Converter class works perfectly.
When I build the project, the errors disappear. However, the designer show the familiar error message:
When I click on the 'Reload the designer' link, the errors return. The worst part of this problem is that I lose all Intellisense on these views.
The error highlights these namespaces:
But you can clearly see that they have been declared correctly:
I'm sure that I have found a solution for this problem before, but after an extensive search just now, I can only find a million posts relating to this error where users have actually made errors. Please also note that this was a brand new WPF Application and not downloaded from the internet or a network drive.
Is the project ON a network drive? XAML has issues with projects stored on a network drive. In corporate environments your Documents are often remapped to a network path, causing this problem for the default project folder.
Try like c:\projects\yourprojecthere instead?
WPF Project on a network share with clr-namespace

Qooxdoo xhr.js cannot be located

The current project i am working on consists of 2 parts. 1 part is a
qooxdoo app. And the other is a html file that will be rendered in the
browser widget of qooxdoo.
I recently had to make some changes to the second part (not touching
qooxdoo).
After i copied over the files i needed to connect the Qx app to the html
page. Then it gave me some errors.
I taught if i rebuild, they might go away (they did not).
I get the following error:
LOG: 003045 qx.core.Init: Load runtime: 3044ms
SCRIPT5: The system cannot locate the resource specified.
Xhr.js, line 375 character 9
I have looked and the file is located where it should be.
Does anyone has any idea how to fix this or what is causing it?
It was rather silly, i placed one too many parenthesis and that caused the error. I had trouble finding it since the 2 where very unrelated.

Check CopyLocal property of all references post/during build in multi project solution (Multi Xap)

I have a Silverlight solution that has multiple silverlight projects (Views) that all compile to their own .Xap file.
There is one "master" project that handles the dynamic downloading of the Xap files, which works pretty well.
But now I need to make sure that all the references are set to CopyLocal=false in all the View Projects. Only the "master" project can have CopyLocal=true.
This means that the Xap files generated by the Views stay rather small.
What I would like to do is check post or during the build process to see if any of the View projects have a reference with CopyLocal=true.
What would be a smart way of doing this? Using an external tool in the Post Build event? Or perhaps an addin for Visual Studio ? Or creating a macro in Visual Studio for this?
I have looked at using .extmap with assembly caching, but since you have to specify the assemblies in that, this does not solve my problem. I just need to know if there is a reference with the wrong setting and report that. Fixing it is not the question, that will still be done manually. It's just the notification I need.
Solution has 35 projects now, so dont want to check them all by hand every time.
I found a question similar to this one, but it lists msbuild as a possible solution. I would like to know if there is a way to do this using "code" (be it prebuilt in a tool/addin or otherwise)
I have chosen to go the Addin path. I created an addin that listens to : BuildEvents.OnBuildBegin
Whenever that event fires I create a list of all projects in the current solution. Doing a bit of recursive searching since there are also Solution folders that make life in DTE world a bit harder.
Then I loop through all the projects and cast them to a VSProject so I can loop through all the references.
Anytime I come accross a reference that is wrong, I create an ErrorTask where I set the Document property to the full solution path of the reference. To do this I Build the path for the project this reference is in, all the way up to the root of the solution.
The ErrorTask is then sent to an ErrorListHelper class I created, that handles the ErrorTasks and also performs navigation.
If I'm done with all the projects and I found any errors, I cancel the current build and show the Error List window, where my ErrorListHelper holds all the Reference Errors I created.
Whenever I want to navigate to the Reference in question, I activate the Solution Explorer window and get the root of it using an UIHierarchy.
Then I walk the path from the root on down, step by step, using the UIHierarchy to get to the UIHierarchyItems and expand them. Until I get to the deepest level (the reference) and I Select that.
Since I only need it for a certain solution and within that solution for certain projects (.Views.* and .ViewModels.*) I also have some checking for those in place during buildup of the Error List.
It works like a charm, already found 12 "wrong" References in 35 projects where I tought all were well.
I am using a different path now to do this. I have a base class that I can use to write unit tests that have access to the DTE2 object. This way I dont need an addin. This also works for Silverlight projects since the test class does not actually need access to the Silverlight projects, just being in the solution is enough to be able to iterate through the projects and check the references.

Resources