0 Comments

Back in 2012, I found some code online which should have been a Nuget package. I tried to reach out to the original author (even searched for him/her today) but could not find any contact info.

That person created a library to generate QR codes. I packaged it for nuget which was just 1,5 years old back then.

The package is still out there. I don’t have any code on my system for years from that lib. But you can still grab the package here: https://www.nuget.org/packages/MessagingToolkit.QRCode/ 

Or from the package manager in Visual Studio with:

Install-Package MessagingToolkit.QRCode

It has been downloaded over 61.000 times now! So Twitt88 did a great job coding it!


I am porting an other 4 to 6 year old library to .Net Standard 1.4. The current status is up on GitHub https://github.com/jphellemons/PhotoBucketNetStandard

And the Nuget package has been submitted. This one is originally build by Mark Schall so most of the credits are for him. I only rewrote the stuff that is not available in .Net Standard or requires other namespaces.


Let’s all port libs to .Net Standard!

Good luck!

Pin on pinterest Plus on Googleplus Post on LinkedIn
0 Comments

There are various options to build a word document in your C# code, I choose the lightweight docx nuget package. There are some really good examples on the Codeplex website of docx http://docx.codeplex.com/ if you look at the “Advanced Examples”

The thing is that Office products tend to localize variables such as table designs:

image

I am dutch, but I cannot translate it to a value of the enum `TableDesign`

If I would translate it, it would be something like listtable 7 colorful accent 6. It is still (even after this test file) not a valid entry of the table design enumeration.

using (DocX document = DocX.Create("C:/Temp/tables.docx"))
{
    foreach (TableDesign td in (TableDesign[])Enum.GetValues(typeof(TableDesign)))
    {
        Table aTable = document.InsertTable(5, 5); // because office preview is also 5 x 5
        aTable.Design = td;
        aTable.Rows[0].Cells[0].Paragraphs.First().Append(td.ToString());
    }
    document.Save();
}

 

The “source” (all 6 lines of code, lol) is available on github https://github.com/jphellemons/DocxTables but perhaps more important is the output file. This might save you some time. https://github.com/jphellemons/DocxTables/raw/master/tables.docx

 

Good luck with this small, but awesome nuget package!

Pin on pinterest Plus on Googleplus Post on LinkedIn
0 Comments

To start serving ads in your Windows Phone application you can install the Microsoft advertising SDK. But I believe it is not mandatory. You do not need to reference it in your project. So please take a look at the screenshot below and make sure you do not check that box!

2014-04-25 15_30_38-Reference Manager - Zaklamp

I recommend using the (not yet final) Adrotator V2. It is the successor of V1 and has an XML configuration file which can be put somewhere online (remote) so that you can edit advertising preferences without needing to update the whole app and push it to your users.

You can get it from nuget as long as you make sure that you can view the pre-releases or put this in the packagemanager console:

Install-Package AdRotatorWP -Pre

That will pull down the package. The readme file will open in a tab and tell you to manually add more DLL’s for mobfox, smaato etc. (only adduplex is included because they have a nuget package).

You should mark your XML config file in the project explorer as content and copy to output always and check the app’s permissions, because mobfox requires <Capability Name="ID_CAP_IDENTITY_DEVICE" />  as found on http://wpunifiedad.codeplex.com/discussions/436059

It took me a while to figure that one out. You have to add this namespace in the XAML in order to use the adrotator component.

<phone:PhoneApplicationPage
    xmlns:adRotator="clr-namespace:AdRotator;assembly=AdRotator"
...>

Good luck!

Pin on pinterest Plus on Googleplus Post on LinkedIn
0 Comments

Here is a small C# code snippet to upload an XML file to an explicit SSL secured FTP server.

When you search nuget for FTP you will get:

image

But which one do you need? Not all of them support FTPS. Well the checkbox gives it away.

If you search for FTPS you will only get these seven results (at this moment):

image

So you need the System.Net.FtpClient from https://netftp.codeplex.com/

And here is the C# code to upload an XDocument to an FTPS server:

private void UploadFile(XDocument xDoc, string filename)
{
    using (FtpClient fc = new FtpClient())
    {
        fc.Credentials = new NetworkCredential(username, password);
        fc.Host = hostname;
        fc.EncryptionMode = FtpEncryptionMode.Explicit;
        fc.ValidateCertificate += fc_ValidateCertificate;
        fc.Connect();
        fc.SetWorkingDirectory("/uploaddir");

        using (var ftpStream = fc.OpenWrite(filename, FtpDataType.Binary))
        {
            if (ftpStream != null)
            {
                xDoc.Save(ftpStream);
                ftpStream.Close();
            }
        }
    }
}

static void fc_ValidateCertificate(FtpClient control, FtpSslValidationEventArgs e)
{
    e.Accept = true;
}

Self signed certificates will otherwise always cause an exception in the ftp libraries because the certificates are not really valid. So you manually have to “validate” it.


Good luck!

Pin on pinterest Plus on Googleplus Post on LinkedIn