SyncSvcUtilUI can't read its own sync configuration - c#

I tried to use Microsoft's Syn Framework Toolkit: http://www.microsoft.com/en-us/download/details.aspx?id=23217
And as I intend to use an Android client, I also downloaded the Toolkit for it: http://code.msdn.microsoft.com/wpapps/Sync-Framework-Toolkit-4dc10f0e
I installed the SDK, then extracted the Toolkit and built it with VS.
Following the instruction in the help file, I used SyncSvcUtilUI to create a Sync configuration file. It went through as planned.
The next step would be to use that configuration file to provision the database. After I select the aforementioned Sync configuration file, I get this message:
Running SyncSvcUtil command...
Invalid parameter passed
Parameter name: Sync
Aren't the two applications compatible with each other? What should I check? The two executables are in the same directory.

The directory that contained SyncSvcUtilUI had space in its name. After moving it to a simple directory, it worked. Great software design...

Related

Accessing Published Version Number In .Net6 Windows Forms App [duplicate]

I have a windows forms application that is deployed to two different locations.
Intranet - ClickOnce
Internet - Installed on a citrix farm through Windows installer
I display ClickOnce version number for click-once deployed versionApplicationDeployment.IsNetworkDeployed.
if (ApplicationDeployment.IsNetworkDeployed)
return ApplicationDeployment.CurrentDeployment.CurrentVersion;
But for the non-click application, I am not sure how to retrieve clickonce version unless I hardcode the version number in assembly info.
Is there an automatic way of retrieve ClickOnce version number for non-clickonce deployed version?
Add an assembly reference to System.Deployment to your project.
Import the namespace in your class file:
VB.NET:
Imports System.Deployment.Application
C#:
using System.Deployment.Application;
Retrieve the ClickOnce version from the CurrentVersion property.
You can obtain the current version from the ApplicationDeployment.CurrentDeployment.CurrentVersion property. This returns a System.Version object.
Note (from MSDN):
CurrentVersion will differ from UpdatedVersion if a new update has
been installed but you have not yet called Restart. If the deployment
manifest is configured to perform automatic updates, you can compare
these two values to determine if you should restart the application.
NOTE: The CurrentDeployment static property is only valid when the application has been deployed with ClickOnce. Therefore before you access this property, you should check the ApplicationDeployment.IsNetworkDeployed property first. It will always return a false in the debug environment.
VB.NET:
Dim myVersion as Version
If ApplicationDeployment.IsNetworkDeployed Then
myVersion = ApplicationDeployment.CurrentDeployment.CurrentVersion
End If
C#:
Version myVersion;
if (ApplicationDeployment.IsNetworkDeployed)
myVersion = ApplicationDeployment.CurrentDeployment.CurrentVersion;
Use the Version object:
From here on you can use the version information in a label, say on an "About" form, in this way:
VB.NET:
versionLabel.Text = String.Concat("ClickOnce published Version: v", myVersion)
C#:
versionLabel.Text = string.Concat("ClickOnce published Version: v", myVersion);
(Version objects are formatted as a four-part number (major.minor.build.revision).)
No I do not believe that there is a way. I believe the ClickOnce information comes from the manifest which will only be available in a ClickOnce deployment. I think that hard coding the version number is your best option.
I would simply make the assembly version of the main assembly the same as the CLickOnce version every time you put out a new version. Then when it runs as a non-clickonce application, just use Reflection to pick up the assembly version.
Try thread verification:
if (ApplicationDeployment.IsNetworkDeployed)
{
if (ApplicationDeployment.CurrentDeployment.CurrentVersion != ApplicationDeployment.CurrentDeployment.UpdatedVersion)
{
Application.ExitThread();
Application.Restart();
}
}
not that it matters three years later, but I ended up just parsing the manifest file with xml reader.
To expand on RobinDotNet's solution:
Protip: You can automatically run a program or script to do this for you from inside the .csproj file MSBuild configuration every time you build. I did this for one Web application that I am currently maintaining, executing a Cygwin bash shell script to do some version control h4x to calculate a version number from Git history, then pre-process the assembly information source file compiled into the build output.
A similar thing could be done to parse the ClickOnce version number out of the project file i.e., Project.PropertyGroup.ApplicationRevision and Project.PropertyGroup.ApplicationVersion (albeit I don't know what the version string means, but you can just guess until it breaks and fix it then) and insert that version information into the assembly information.
I don't know when the ClickOnce version is bumped, but probably after the build process so you may need to tinker with this solution to get the new number compiled in. I guess there's always /*h4x*/ +1.
I used Cygwin because *nix scripting is so much better than Windows and interpreted code saves you the trouble of building your pre-build program before building, but you could write the program using whatever technology you wanted (including C#/.NET). The command line for the pre-processor goes inside the PreBuildEvent:
<PropertyGroup>
<PreBuildEvent>
$(CYGWIN_ROOT)bin\bash.exe --login -c refresh-version
</PreBuildEvent>
</PropertyGroup>
As you'd imagine, this happens before the build stage so you can effectively pre-process your source code just before compiling it. I didn't want to be automatically editing the Properties\AssemblyInfo.cs file so to play it safe what I did was create a Properties\VersionInfo.base.cs file that contained a text template of a class with version information and was marked as BuildAction=None in the project settings so that it wasn't compiled with the project:
using System.Reflection;
using EngiCan.Common.Properties;
[assembly: AssemblyVersion("0.$REVNUM_DIV(100)$.$REVNUM_MOD(100)$.$DIRTY$")]
[assembly: AssemblyRevisionIdentifier("$REVID$")]
(A very dirty, poor-man's placeholder syntax resembling Windows' environment variables with some additional h4x thrown in was used for simplicity's/complexity's sake)
AssemblyRevisionIdentifierAttribute was a custom attribute that I created to hold the Git SHA1 since it is much more meaningful to developers than a.b.c.d.
My refresh-version program would then copy that file to Properties\VersionInfo.cs, and then do the substitution of the version information that it already calculated/parsed (I used sed(1) for the substitution, which was another benefit to using Cygwin). Properties\VersionInfo.cs was compiled into the program. That file can start out empty and you should ignore it by your version control system because it is automatically changing and the information to generate it is already stored elsewhere.
Hard code, or... Keep track on your versions (File, Assembly, Deploy) in a database. Make a call to the database with your Assembly and get the Deploy version.
This assumes that you are incrementing your versions in a logical way such that each version type has a relationship. It's a lot of work for such a minor problem. I'd personally go with Jared's solution; although I hate hard coding anything.
Using a build component, you could read the click-once version from the project file and write it automatically to the assembly info so both of them are in sync.
Solution for .NET (Core) 7 and higher
On .net Core, you can read the version number from the environment variable ClickOnce_CurrentVersion.
string versionString = Environment.GetEnvironmentVariable("ClickOnce_CurrentVersion") ?? "0.0.0.0";
Version version= Version.Parse(versionString);
MessageBox.Show(version.ToString());
See documentation

How to make a setup for c# app that uses a vbscript copying a file from LAN?

So i Have this c# application that contains a button allowing a file copy from a network share folder.i use a vbscript to copy the file, this script takes the source and destination path.now i want to create a setup to install my application on any PC connected to the LAN. the thing is the path will eventually change so i'm not sure if it will work.
I never made a setup before and i'm wondering if there is a way to customise the setup to allow the installer to make the changes.otherwise any solution will be very helpfull. thank you
I don't normally like giving answers that are mostly links, but it is too much to post here. Here is a quick summary:
There are quite a few things that can do what you are asking.
The one I like is called Squirrel. I recently had to learn how to use it while deploying an application for my company.
The steps in a nutshell(see what I did there? :)
Build your application (optionally add the update checker code
first - see links for details)
Package your application into a .nuget file using Nuget Package Explorer(details in links below)
Run the squirrel --releasify on your nuget
It will output the setup files that you are looking for in the Releases directory.
More information (that you will likely need):
Github - Squirrel.Windows
Youtube - Video tutorial that I found helpful
Github - Squirrel Getting started guide
As for your vbscript, I would do the file copy inside C#. You are very likely to run into permissions issues when using vbs. In any case, why add the complexity of 2 different languages when C# can do a file copy easily.
Something like this during your application's startup.
if (File.Exists(localFileName) == false) // check to see if the file is needed
{
File.Copy(sourceFileOnLan, destinationFile); // get the file
}
If you are really set on using a vbs file, you can launch it using Process.Start() and let Windows execute it.
Also, you can store the paths in your app.config file, and update them if/when they change.

How to save the excel output in C# offline?

I have created a simple and basic Hello World template with the sample coding I found in OfficeWriter. However, I want to save the output in a folder inside the computer, not store online (web)
The website have already stated how to save to a folder but it is not working in my case. Anyone can help on this? By the way, I used a console application to do the coding.
The error mentions that I must add System.Web reference which I think it is not necessary since I am not doing a web or something.
using SoftArtisans.OfficeWriter.ExcelWriter;
namespace ConsoleApplication1
class Program
{
static void Main(string[] args)
{
ExcelTemplate XLT = new ExcelTemplate();
XLT.Open(#"C:\Users\administrator\Desktop\Hello World.xlsx);
DataBindProperties dataProps = XLT.CreateDataBindingProperties();
string value = "Hello World";
XLT.BindCellData(value, "DataValue", dataProps);
XLT.Process();
XLT.Save("Output.xlsx"); //this coding is giving me problem.
}
}
Note: I work for SoftArtisans, makers of OfficeWriter.
Although most of our customers use OfficeWriter in .NET web applications, OfficeWriter can be used in any type of .NET application.
All OfficeWriter objects (ExcelTemplate, ExcelApplication, WordTemplate, and WordApplication) have four output options:
Save directly to disk
Save to System.IO Stream
Stream the generate file to the client as an attachment
Stream the generated file to the client to be viewed in the browser. This only works for Internet Explorer and if viewing Office files in IE is enabled.
The Save method has a dependency on System.Web due to the Save() overloads that use the HttpResponse object. I know customers have run into trouble with the dependency if they were using the .NET 4 client profile because a reference to System.Web is not included automatically. I believe the same is also true for projects like console or forms applications.
To save a file to a particular folder on disk, you will need to provide the full file path to the location on disk. For example "C:\Reports\SampleReport.xlsx". You can use .NET code to help resolve the full file path before passing that value to OfficeWriter.
Here are a couple posts I found that discuss how to get the full file path from a .NET console application:
How can I get the application's path in .NET in a console app?
How to get a path from a directory in a C# console application?
According to the ExcelTemplate.Save() documentation, the file is being saved to the server, even though you do not think it is. Since it is trying to save to the web server, System.Web is needed to resolve the physical path on the server.
You are using the wrong tool then. Directly from the documentation of Excel Writer 7...
SoftArtisans ExcelWriter is a high-performance pure .NET solution that
generates native Microsoft Excel spreadsheets on a Web server. A few
simple lines of code generate editable presentation-quality
spreadsheets that can be saved on the server or viewed instantly by
thousands of concurrent users.
http://wiki.softartisans.com/pages/viewpage.action?pageId=3114609
Look into using Visual Studio Tools for Office or some other library to satisfy your local Excel needs.
You should try adding the System.Web reference to see if that fixes your problem. The System.Web assembly is already installed with the full .NET framework, so it doesn't change anything if you reference it or not. Maybe it will detect that you're not in a web application and save it anyway, but it needs the reference to do so.
Alternatively, use the open source EPPlus project to create Excel spreadsheets and System.Web will not be required - http://epplus.codeplex.com/
Okay, I found the answer to that problem, I just have to add the web reference to the project and it worked like magic. Once again I thank you all for the help rendered.

What is needed to run XSP as a standalone server on Windows?

I'm trying to setup a minimal copy of XSP for Windows for students to use in an ASP.NET intro course. They have Visual C#, and I don't want to confuse matters by giving them Mono per se. I don't want to use IIS for various reasons. I did a similar thing previously for JSP with a zipped copy of Jetty, which worked splendidly.
As an experiment I've installed Mono 2.10.9, and can successfully run XSP directly from the installation. However, the executable (xsp2.exe) is in lib\mono\2.0\winhack, and the server environment is in lib\xsp\test. I want to create a directory containing a minimal set of files (xsp2.exe, xsp.exe.config, Mono.WebServer2.dll, and whatever else is needed) which I can zip up and give to the students. However, all I get is a "File Not Found" exception for Mono.WebServer2.
I copied Mono.WebServer2.dll across, and then got the same for Mono.Security. When I copied Mono.Security.dll, the error refers to Mono.WebServer2 "or one of its dependencies" (without telling me which one).
Can anyone tell me what I need as a minimal setup please?

Bringing C# application under assembly version and using it to create patches and manage them

We have a C# desktop application which we run for clients on various servers on a software as a service model. We are still on dot net framework 2.
The software has a architecture in which we have an independent application to catch external data thrown by some server. Then an application to make calculations based on it. Also one more application on which the client sees the output. The link between the 3 applications is another application which communicates with the DB.
The 4 solutions are on a SVN for sourcecontrol. But the release management is still manual and the patches are made manually by checking the log and including the dlls, pdbs, xml. etc for the projects for which the code has changed.
There is no assembly versioning implemented and the patch or release management is just done in the dark.
I want to know what is the industry practice for generating automatic patches from the code. Also I want a patch for each revision in the SVN. Also is assembly versioning helpful in this?
I have read much about continuous integration but it fails because we do not have unit tests and other fancy code to moniter the correctness of code.
The only thing at this time I would be interested is to implement a way to make patches which can be applied and removed easily. Also I want to know a way to determine the way we can monitor which release is at which level(or what patches have been applied) by some automated way rather than maintaining a log manually.
We use a build script which creates a SvnVersion.cs file containing the last commited revision. This file is placed in the root of the solution, and then added to all projects in the solution (but added as a link, not copied).
The template for the file (SvnVersion.Template.cs) looks like this:
using System.Reflection;
[assembly: AssemblyVersion("1.0.0.$WCREV$")]
[assembly: AssemblyFileVersion("1.0.0.$WCREV$")]
And we simply use TortoiseSVN to fill these placeholders in a batch script:
type "%TRUNKPATH%SvnVersion.Template.cs" > "%TRUNKPATH%\SvnVersion.tmp"
SubWcRev "%TRUNKPATH%\" "%TRUNKPATH%SvnVersion.tmp" "%TRUNKPATH%SvnVersion.cs" -f
IF ERRORLEVEL 1 GOTO ERROR
DEL "%TRUNKPATH%SvnVersion.tmp"
If you don't use TortoiseSVN, there are other ways to get this info in the file.
You will also need to remove this same information from your AssemblyInfo.cs files or you'll get a compile error. Also, to speed up Debug builds, this is only executed in Release builds (and in Debug builds only if the file doesn't initially exists, like after a fresh checkout).

Categories

Resources