Visual Basic function IsDate depends on Current Culture.

I was puzzled when VB function IsDate(20/02/2006) returned false( in Australia date format is dd/mm/yyyy).


After investigation using Reflector I found that it uses  Thread.CurrentThread.CurrentCulture and my ASP.NET application wasn’t set to use AU culture by default. Using CurrentCulture does make sense, but it is not documented in MSDN. 


 

DotNetNuke “Upload Custom Module” command sometimes does nothing.

I’ve noticed a few times that when in DotNetNuke 4. “Upload Custom Module” page I had a custom module in the list, “upload new file“ link does nothing instead of importing module.


It seems related to caching issue (see problem here). I suspect that even if the file is shown in the list, it still not in cache.


It will be more reliable to check list control directly instead of cache. And why the list to upload should be saved to cache? 


Additionally even if the list is empty, it is better to report about it to the user instead of silently return to module list.


The issue has been reported to DNN Support


The workaround is described here

Backup source files using MSBuild project.

I wanted to create batch to backup source files from my Projects folder, but also exclude some folders that I do not use.


I was amased how quickly I was able to do it using MSBuild project without any previous experience with the tool.


I’ve posted details  here. 

Backup source files using MSBuild project.

I wanted to create batch to backup source files from my Projects folder, but also exclude some folders that I do not use.

I was amased how quickly I was able to do it using MSBuild project without any previous experience with the tool.

The purpose of the project is to copy files with specified extensions from specified folder and all subfolders, excluding some subfolders

The Destination folder name is generated based on current time.

The batch file to start utility:

call “C:Program FilesMicrosoft Visual Studio 8VCvcvarsall.bat” x86
msbuild.exe /v:m BackupSrc.xml

The BackupSrc.xml project file is the following:

<Project xmlns=http://schemas.microsoft.com/developer/msbuild/2003>

  <PropertyGroup >

    <ExcludeFolders>C:ProjectsSamples***.*;C:ProjectsWebSites***.*ExcludeFolders>

    <SrcPath>C:Projects***.SrcPath>

  </PropertyGroup>

  <ItemGroup>

      <!–              Extensions=”aspx,vb,GIF,JPG,sln,CS,vbProj,csProj,vdproj,cpp,h,config,resx,SQL,DOC,bat,cmd,cst”;–>

      <MySourceFiles

        Include=$(SrcPath)aspx;$(SrcPath)vb;$(SrcPath)GIF;$(SrcPath)JPG;$(SrcPath)sln;$(SrcPath)CS;$(SrcPath)??Proj;$(SrcPath)cpp;$(SrcPath)h;$(SrcPath)config

               Exclude=$(ExcludeFolders) />

      <MySourceFiles

        Include=$(SrcPath)resx;$(SrcPath)SQL;$(SrcPath)DOC;$(SrcPath)rtf;$(SrcPath)bat;$(SrcPath)cmd;$(SrcPath)cst;$(SrcPath)htm;$(SrcPath)html;$(SrcPath)txt

               Exclude=$(ExcludeFolders) />

    </ItemGroup>

    <UsingTask TaskName=FolderName

                  AssemblyFile=C:ProjectsUtilitiesMSBuildCustomTasksbinDebugCustomTasks.dll />

    <Target Name=CopyFiles>

      <FolderName>

        <Output TaskParameter=FolderNameAsNow PropertyName=FolderDate />

      </FolderName>

      <Copy

          SourceFiles=@(MySourceFiles)

          DestinationFiles=@(MySourceFiles->’C:BackupsVS2005Projects$(FolderDate)%(RecursiveDir)%(Filename)%(Extension)’)

        />

   </Target>

    <!–Access  Extensions=”mdb,adp,bas,pks,bat,vbs,xml”; –>

 </Project>

 

Note that XML is slightly corrupted by HTML editor that Iam using for blogging. 

 

 

I’ve also created a CusomTasks.DLL to create a FolderName by formatting  the current date.

 

 

using System;

using System.Collections.Generic;

using System.Text;

 

namespace CustomTasks

{

    using Microsoft.Build.Framework;

    using Microsoft.Build.Utilities;

 

        public class FolderName : Task

        {

            public override bool Execute()

            {

                myFolderNameAsNow = GetDateTimeFolder();

                return true;

            }

 

            private string myFolderNameAsNow;

            [Output] // attribute is important

            public string FolderNameAsNow

            {

                get { return myFolderNameAsNow; }

                set { myFolderNameAsNow = value; }

            }

            private static string GetDateTimeFolder()

            {

                return “F_” + DateTime.Now.ToString(“yyMMdd_HHmm”);

            }

 

    }

}

MSBuild Related links: MSBuild Community Tasks Project ,

Sdc.Tasks on gotdotnet,

subtree copy task,

SetMetadata sample on Visual Studio MSBuild forums, 

Microsoft Build Sidekick

 

Less related to the article links about MSBuild:
How to call the same target multiple times at different build stages?

 

Alternatively see free

 

ROBOCOPY.exe (XP Resource Kit/Standard Vista command)

JaBackAutomated Data Backup Software, File Backup Software 

Support of multiple module definitions in DotNetNuke import/install.

Current version of DNN(4.0.2) doesn’t support multiple module definitions when importing templates


The issues are listed on DNN support site. By some reason comments for the issue are not allowed.


So I will post here  my suggestion how to resolve problem 3 (the imported result the page will contain duplicate modules, one for each moduledefinition).


DNN portal Template XML has <definition> element in the section.


However it does saves ModuleName instead of ModuleDef.Name.


To fix a problem the ModuleDefinition name should be saved in the <definition> element (Is it logical?)


The change should be done in  adminPortalTemplate.ascx.vb, function SerializeTabs, line ~ 464.


The similar change should be done in DNNLibraryComponentsPortalPortalController.vb function ParsePanes, , line ~1288. The code should call ModuleController.GetModuleByDefinition.


Module Definition names are expected to be unique, so there is no need to store combination of DesktopModule name and ModuleDefinition names  in the template.


Note that it will be  a breaking change, because old templates will use Module names instead of Module Definition name.
It will be required to change XML version and have code branches to support both old a new templates.


Consider that it is not a simple change, I desided not to implement it in my local DNN, but just split modules with multiple module definitions into separate modules.


I hope that future versions of DNN will address the issue.

DotNetNuke Install deletes zip files from Install resources subfolders

I was surprise that after successfull installation of DotNetNuke custom module ZIP files from InstallModules sub-directory were deleted.


I’ve checked the code – it’s done by design.


But it should be documented in DotNetNuke Installation Guide.pdf

DNN 4.0 loads Provider classes with case-sensitive names.


I’ve rebuild ”DotNetNuke.Modules.Html.SqlDataProvider’.DLL’ from the downloaded source code and started to receive errors: 


System.TypeLoadException: Could not load type ”DotNetNuke.Modules.Html.SqlDataProvider” from assembly ”DotNetNuke.Modules.Html.SqlDataProvider”.
   at System.RuntimeTypeHandle._GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, Boolean loadTypeFromPartialName)
   at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
   at System.RuntimeType.PrivateGetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
   at System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)
   at System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)
   at System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError)
   at DotNetNuke.Framework.Reflection.CreateObject(String TypeName, String CacheKey, Boolean UseCache) in C:ProjectsDNNLibraryComponentsSharedReflection.vb:line 241


After investigation I noticed that caller specify provider namespace as ”DotNetNuke.Modules.Html”, but the actual namespace in SqlDataProvider’.vb is ”DotNetNuke.Modules.HTML“.


Because current code in DotNetNuke.Framework.Reflection.CreateObject loads case-sensitive names, the error occured.


It will be bettter to change core code to use BuildManager.GetType overload that ignores case.


objType = BuildManager.GetType(TypeName,

True, True)


I’ve reported a bug in DNN support. Update: It will be fixed in DNN 4.1