Dynamics CRM 2011 - dynamics-crm-2011

I am new to Dynamics CRM 2011 Online. I am try to generate the data context class using CrmSvcUtil.exe
This is my command:
CrmSvcUtil.exe /out:E:\OrgXrm.cs
/url:https://mdtestuser.api.crm5.dynamics.com/XRMServices/2011/Organization.svc
/username:MDTest#MDTestUser.onmicrosoft.com /password:Password
But its giving an error:
Exiting program with exception: An error occurred when verifying
security for th e message. Enable tracing and view the trace files for
more information. CrmSvcUtil.exe Error: 0 : Exiting program with exit
code 2 due to exception : Sy stem.ServiceModel.FaultException: An
error occurred when verifying security for the message.

I was researching another issue when I ran across a post in the Microsoft forums that may help. I remembered this question so I thought I would post another answer as this one had a positive resolution.
Quote:
I have dealt with this one before. Verify the Time and Date settings (including timezones) are set correctly on both the server and your client machine. It seems that if the two machines are out of sync by more than a minute or two it will cause this problem.
On my client machine I had to restart Visual Studio also for some reason after I set the server clock to get it to connect up properly.
http://social.microsoft.com/Forums/en-US/0ad9a5ee-dcce-4146-a1e6-20eafdccff46/crmsvcutil-error-an-error-occurred-when-verifying-security-for-the-message?forum=crmdevelopment

To fully understand your error, you should use config file with enable tracing, here is an example of config file:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="servicecontextname" value="XrmServiceContext"/>
<add key="codecustomization" value="Microsoft.Xrm.Client.CodeGeneration.CodeCustomization, Microsoft.Xrm.Client.CodeGeneration"/>
<add key="username" value="domain\user"/>
<add key="password" value="password"/>
<add key="out" value="XrmEntitiesReference.cs" />
</appSettings>
<system.diagnostics>
<trace autoflush="false" indentsize="4">
<listeners>
<add name="configConsoleListener" type="System.Diagnostics.ConsoleTraceListener">
<filter type="System.Diagnostics.EventTypeFilter" initializeData="Error" />
</add>
</listeners>
</trace>
</system.diagnostics>
</configuration>
check out example from here:
http://www.resultondemand.nl/support/sdk/06abab26-40fc-4b85-9a2a-5e68903ea138.htm

JIC somebody get the same error.
I made the connection and I were able to generate the context from CRM online. The unique difference is in the URL, I have the next:
https://architecture2.api.crm.dynamics.com/XRMServices/2011/Organization.svc
You see this say crm not crm5 but that depends on your organization, to get the rigth one:
Open your organization then Settings->Customizations->Developer Resources->Organization data service
My command line to execute CrmSvcUtil.exe is:
CrmSvcUtil.exe
/url:"https://architecture2.api.crm.dynamics.com/XRMServices/2011/Organization.svc"
/out:"E:\Context.cs"
/username:MyUser#architecture2.onmicrosoft.com
/password:Password
Something else the account should have the required permissions, my account has System Administrator role.

I realize this is a long-shot, but has your password changed recently?
With a command string like this, a lot of people use .bat files to automate the process.
I dislike using passwords in .bat files because:
They are not secure (obvious, I know)
Maintenance. Every time you update your password, you would have to remember to update every script. Or painfully troubleshoot every failure and finally remember that the password was embedded.
To mitigate this I use SET with a /P parameter to prompt for a password during .bat file execution.
Not perfect, but a lot better than hard coding a password.
Here is an example using the command string you supplied:
rem ----- begin script -----
SET /P pwd=Password:
CrmSvcUtil.exe /out:E:\OrgXrm.cs /url:https://mdtestuser.api.crm5.dynamics.com/XRMServices/2011/Organization.svc
/username:MDTest#MDTestUser.onmicrosoft.com /password:%pwd%
CLS
SET pwd=.
rem ----- end script -----
In this example the SET /P tells the command processor to set an environment variable and prompt for the input.
“pwd” is the environment variable being set.
“%pwd%” is the actual use of the environment variable.
“Password:” is the prompt string that will be displayed when the .bat file is run.
“CLS” clears the screen.
“pwd=.” sets the environment variable to “.” so the password is not left in the environment.
You can ignore the lines beginning with “rem” as they are simply remarks.
The “not perfect” part of the solution is that your password is visible as you type. However by clearing the screen immediately following the prompt it is cleared from the screen right away. There are other ways to prevent the password from being visible as you type, however I think they are vastly over complicated or require downloading some additional bits. The idea of using a .bat file is that it is quick and easily updatable ergo low maintenance.
The SET /P works well in my case as no one is looking over my shoulder whenever I need to refresh my file, and there is virtually no maintenance once the .bat file is written.

Related

NLog OnNewLogFile Handler?

Is there any event handler or similar that I can hook into, to run some code every time NLog starts a new Log File?
I have an NLog Config like this:
<target name="logfile" xsi:type="File"
fileName="[stuff]"
layout="[more Stuff]"
maxArchiveFiles="4"
archiveAboveSize="102400" />
And I'd kinda like to add some meta-data at the start of every log file (version number, Machine Name, etc. so that every log file comes complete with some contextual information)
I don't expect to be able to configure this text in NLog itself, but I'm hoping that I can tell NLog to run a certain method everytime it's going to create a new Log File.
Is this a thing?
Sounds like you are really looking for the Header-Layout on the FileTarget.
<target name="logfile" xsi:type="File">
<header>--- ${assembly-version} started on ${longdate} ---</header>
</target>
See also https://github.com/NLog/NLog/wiki/File-target
Some combine it with archiveOldFileOnStartup="true" because the Header is only printed when file is created (ensure application restarts will create new file).
You can use FileSystemWatcher.
FileSystemWatcher is watching specific (which you want it) directory, If new file created, handle this event with FileSystemWatcher
For more details : https://learn.microsoft.com/en-us/dotnet/api/system.io.filesystemwatcher?view=netframework-4.8
Another partial solution to the "What version?" aspect of this problem could come from:
https://github.com/NLog/NLog/wiki/AssemblyVersion-Layout-Renderer

Analyzing Coded UI Tests Using Coded UI Test Logs

i am trying to get the html log file for the coded ui tests.
i tried the steps mentioned in the following link
https://msdn.microsoft.com/en-us/library/jj159363(v=vs.110).aspx
By default it generated .png file(image file) which captures only the screenshot of the active window where the error occurred.
So i tried using the other values for "EqtTraceLevel" in the configuration file, but there is no difference, it still generates image file.
Does it work for Windows application? if it does what are the additional settings required?
To enable HTML logging in your tests you should add Playback.PlaybackSettings.LoggerOverrideState = HtmlLoggerState.AllActionSnapshot; to your test.
This will show all steps taken in your test and a corresponding screenshot of your application under test. It will also show you a highlight rectangle to show the found control.
Alternatively change QTAgent32.exe.config or QTAgent32_40.exe.config in C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE (or where you have VS installed) to contain the following settings:
<appSettings>
<!--- Your settings -->
<add key="EnableHtmlLogger" value="true"/>
</appSettings>
And to increase the detail of your logging:
<switches>
<add name="EqtTraceLevel"value="4"/>
</switches>
Where 0 is off, 1 for errors, 2 for warnings, 3 for info and 4 for verbose.

IIS web.config, any other % symbols apart from %s?

Regarding the scriptProcessor in the handlers section of IIS's web.config, are there any % symbols apart from %s (which seems to represent the requested filename)? For example, is %a a recognised macro/symbol? If there are others besides %s, where are they described?
Your question is a bit unclear, so I had to make a number of assumptions in order to answer it. Please let me know if I got anything wrong.
From the documentation:
Script Processor
Optional string attribute.
Specifies the physical path of the ISAPI extension .dll file or Common Gateway Interface (CGI) .exe file that processes the request.
The scriptProcessor attribute is required only for script map handler mappings. When you map a handler to an ISAPI extension, you must specify ISAPIModule for the modules attribute. When you map a handler to a CGI file, you must specify CGIModule for the modules attribute.
From the documentation, we don't see any mention of format strings at all. If there were format strings, what would you replace them with? There's no clear answer based on the XML. Perhaps you're mistaking an environment variable for a format string. Or your particular configuration setup has some post processing that's ran on it before it's pushed live.
If we are actually talking about environment variables, then you can view them by issuing Win+Break to bring up system settings, go to advanced, then open up environment variables. You may also define your own. To use any environment variable you can use %variablename% as you would in a standard .bat file.
EDIT: Upon greater research, I've found the following. %s will give you the script name, then %s again will give you the parameters foo=bar. This feature isn't advertised (that I can find) in any official IIS documentation. I strongly suspect that it's considered a deprecated feature. And they're pushing hard to make ISAPI the norm.
Because of how it's structured (ie like a standard format string) I suspect that trying other common format strings (%d %c %f) might yield you something interesting, but probably not. It looks like this was a very specific solution to a very specific problem.
It's not strictly related to your question but I post these 2 links as they are in some way connected and could be useful.
I've found how to use "#" and "$" to transform Web.Config, but I've found nothing on "%" that's not strictly related to environment variables.
First link: "#"
This first link explains the use of xdt:Transform and xdt:Locator attributes that you can use in Web.config transform files:
http://msdn.microsoft.com/en-us/library/dd465326.aspx
This example is an interesting use of Web.Config transformation using Conditions with "#":
<configuration xmlns:xdt="...">
<connectionStrings>
<add name="AWLT" connectionString="newstring"
providerName="newprovider"
xdt:Transform="Replace"
xdt:Locator="Condition(#name='oldname'
or #providerName='oldprovider')" />
</connectionStrings>
</configuration>
Second link: "$"
This second link shows how to use "$" to transform Web.Config avoiding the boring procedure to manually comment/uncomment Web.Config parts when deploying or testing in different servers:
http://andrewtwest.com/2010/02/25/using-web-config-transformations-in-web-site-projects/
An extract of the link, showing how to use MSBuild to transform Web.Config files starting from a Web Application project file:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\</OutputPath>
</PropertyGroup>

Issue with SubSonic and Multiple Providers

I have two Subsonic-generated Data Access Layers for 2 different databases that I use in one project and so I have the following in my web.config:
<SubSonicService>
<providers>
<add name="BLLDB" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="BLLDB" generatedNamespace="BLLDB" useSPs="true" />
<add name="BLLDB2" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="BLLDB2" generatedNamespace="BLLDB2" useSPs="true" />
</providers>
</SubSonicService>
yet, anytime I call the code for either DAL it always ends up using the second data Provider listed ("BLLDB2"), and so gives an error like "Invalid object name 'dbo.Users'" when it should be reading from "BLLDB" (despite me explicitly specifying "BLLDB" in the Select())
e.g. check the following code for the "BLLDB" DAL:
Dim mySelect As New
SubSonic.Select(Databases.BLLDB)
mySelect.From(Of User)()
"mySelect.ProviderName" returns a string value: "BLLDB2"
whereas "Databases.BLLDB" returns a string value: "BLLDB"
what gives??
One of your provider is failing. Subsonic is not good about telling you why and where its failing.
I usually debug in couple of ways.
Use only one provider at a time and comment the other one. Check if you are able to see the namespace. If both of them load fine, then you atleast know its not the database.
Check if any of you tables start with -, _, or numbers. This can cause it fail as well.
Let me know how it goes.
You can specify which provider is default by using:
< SubSonicService defaultProvider="BLLDB" >
I am new to Subsonic (using version 2.2 with C#). I spent a lot of time trying to get the same configuration as Stimpy to work. I think I figured it out - my solution below. If this is correct, it would be great to add this information to the Select Queries documentation. so others can resolve this multiple data provider issue earlier.
Here's the web.config
<SubSonicService enableTrace="false" templateDirectory="">
<providers>
<clear/>
<add name="DB1" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="DB1" excludeProcedureList="*" generatedNamespace="DB1" includeTableList="TableA" tableBaseClass="RepositoryRecord"/>
<add name="DB2" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="DB2" excludeProcedureList="*" generatedNamespace="DB2" includeTableList="TableB,TableC" tableBaseClass="RepositoryRecord"/>
</providers>
Here's the statement that doesn't work (taken from the Select Queries documentation examples). SQL Server can't find "TableA" because it's looking for it in DB2 instead of DB1:
DB1.TableA doesntWork = new Select().From<DB1.TableA>().
Where("idCol").IsEqualTo(1).ExecuteSingle<DB1.TableA>();
(My assumption had been that the dataProvider for each table would have been generated as a property of the table class).
Here's the modification to make this work:
Select mySelect = DB1.DB.Select();
DB1.TableA works = mySelect.From<DB1.TableA>().
Where("idCol").IsEqualTo(1).ExecuteSingle<DB1.TableA>();
OR, this also works:
DB1.TableA worksAlso = new Select(DataService.GetInstance(Databases.DB1)).From<DB1.TableA>().
Where("idCol").IsEqualTo(1).ExecuteSingle<DB1.TableA>();
It seems that if you have a single dataProvider OR you specify in the SubSonicService config. that the default dataProvider is the one you're trying to use, everything works fine:
<SubSonicService enableTrace="false" defaultProvider="DB1" templateDirectory="">
But, if you leave out the "defaultProvider", it defaults to the last one in the providers list (in this case, DB2)
Another important piece of information for the multiple DAL case - if you generate the code into different folders for each provider, be sure to “include” in your project only ONE of the "AllStructs.cs" files that automatically gets generated into each folder (otherwise, compile errors).
FYI: kudos to the developers of this open source alternative to Codesmith. So far (other than this issue), it's been easy to get started and make it work (especially with SubStage). Also, I think it will end up being a lighter weight, cost-effective solution for my clients. Thank you!
I am using subsonic 2.2 substage. You need to change the namespaces for multiple providers respectfully.
One important thing. It will generate multiple "AllStructs.vb" files. It will be repeated by code automatically. But you need to add single allstructs.vb another just delete and it will work 1000%.
here would be the configuration settings at web config file.
<connectionStrings>
<add name="aspnetdb" connectionString="Data Source=(local); Database=aspnetdb; Integrated Security=true;"/>
<add name="office" connectionString="Data Source=(local); Database=office; Integrated Security=true;"/>
</connectionStrings>
<SubSonicService defaultProvider="aspnetdb" enableTrace="false" templateDirectory="">
<providers>
<clear/>
<add name="aspnetdb" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="aspnetdb"/>
<add name="office" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="office"/>
</providers>
</SubSonicService>
Hi all and thanks for the replies... Rob if I specify the default provider of "BLLDB" this ends up doing the same thing, but for BLLDB instead of BLLDB2
i.e. it only reads from BLLDB and not BLLDB2
CodeToGlory, I'm using the latest dlls and usually have no issues running SubSonic until I came across this prob.
Would it be possible for you to post up the web.config entries you use for subsonic where you have both providers working please?
Thanks a million!
P.S. It's also rather odd that when I specify which data provider to use directly in my Select() function:
e.g.
Dim mySelect As New SubSonic.Select(Databases.BLLDB)
mySelect.From(Of User)()
and then I do:
"mySelect.ProviderName", this returns a string value: "BLLDB2" (not correct)
whereas when I output the value for "Databases.BLLDB" this returns a string value: "BLLDB" (correct)
This could actually be the key to the problem...
Just answering my own question here .. it seems to indeed be NOT possible to use multiple providers when working through VB.NET.
This possibly only works in C# (as CodeToGlory mentioned), as I've tested several different scenarios from scratch and cannot get 2 Subsonic-generated DALs to work side-by-side
Will have to hack my own one together for one of them so.. Cheers for the advice though!

Reproducing the blocked exe "unblock" option in file properties in windows 2003

When I download my program from my website to my windows 2003 machine, it has a block on it and you have to right click on the exe, then properties, then select the button "Unblock".
I would like to add detection in my installer for when the file is blocked and hence doesn't have enough permissions.
But I can't eaisly reproduce getting my exe in this state where it needs to be unblocked.
How can I get the unblock to appear on my exe so I can test this functionality?
This is done using NTFS File Streams. There is a stream named "Zone.Identifier" added to downloaded files. When IE7 downloads certain types of file that stream contains:
[ZoneTransfer]
ZoneId=3
The simplest way to set it is to create a text file with those contents in it, and use more to add it to the alternate stream.
Zone.Identifier.txt:
[ZoneTransfer]
ZoneId=3
Command:
more Zone.Identifier.txt > file.exe:Zone.Identifier
Then, the way for you to check it would be to try to open the Zone.Identifier stream and look for ZoneId=3, or simply assume that if the stream exists at all that your user will receive that warning.
It's also important to note that this has nothing to do with permissions. Administrators see the same warning; it's to do entirely with the source and type of file. The entire stream goes away when users uncheck the "Always ask before opening this file" box and then click Run.
There is a supported API for this, documented on MSDN. Search on MSDN for "Persistent Zone Identifier Object". Basically you CoCreateInstance with CLSID_PersistentZoneIdentifier and request an IPersistFile interface. You then call IPersistFile::Load with the name of the file in question. Next, QI for an IZoneIdentifier interface and use IZoneIdentifier::GetId to obtain the zone of the file. If there was no "mark of the web", you should get URLZONE_LOCAL_MACHINE. The ZoneId of 3 mentioned in the other reply is URLZONE_INTERNET. (The enumeration is called URLZONE and is also documented on MSDN, or see sdk\inc\urlmon.h.) You can remove or change the "mark of the web" by calling IZoneIdentifier::Remove or IZoneIdentifier::SetId and then call IPersistFile::Save. There are more details about all of this on MSDN. Good luck!
Thanks for this it helped me a lot.
You can make the process even easier if you create a batch file with the contents.
echo [ZoneTransfer] > Zone.Identifier
echo ZoneId=3 >> Zone.Identifier
more Zone.Identifier > %1:Zone.Identifier
This will generate the Zone.Identifier for you and mark the file accordingly.
To run it just supply the file name e.g. if the file is called mark.bat
mark.bat myfile.txt

Resources