Monday, March 27, 2017

SharePoint 2013 DateTime and DateTime format sample

SharePoint 2013 DateTime and DateTime format sample:


This was surprisingly hard to find for me.

Monday, March 13, 2017

Buggish: MySql.Data, unable to compile

Error    1    Could not load file or assembly 'MySql.Data, Version=, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. Strong name signature could not be verified.  The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)
My Solution: Use the stable version in Visual Studio 2013 NuGet Package.

My steps I think I've taken:
1. Used NuGet Package to install latest version (7.0.6)
2. Attempted to compile, completed compile then realized that dll was not in the bin folder
3. I didn't realize that NuGet Package is saved in the packages folder, so I downloaded the source mysql-connector-net-6.9.9-src
4. Compiled
5. While trying to find my project folder, I stumbled onto the package folder so I used Add Reference to add the dll for 7.0.6.
6. Compiled, and I got a similar as the one above. (Unsure if the version is the same)
7. I removed the reference and tried to reinstall via NuGet (received similar error)
8. Repeated several times with the compiled code, modifying web.config, restart, reboot
9. Finally, I tried to download the latest stable version.

I am not familiar with NuGet, assemblies, and GAC. I am familiar with the terms but usually have worked by following directions so have not delved into them much before. I do not think my understanding has increased any bit after this either, but hopefully this help someone as I haven't seen this solution.

Wednesday, March 8, 2017

Buggish: Visual Studio 2017 - The designer encountered an error while loading the table definition

The designer encountered an error while loading the table definition


Restarting computer

Failed Attempts

  • Tried reconnecting to Azure db
  • Tried restarting Visual Studio 2017
  • Tried using Visual Studio 2015

Other Odd Behaviors

This was the first time using Visual Studio 2017 (just installed).
An empty web project created.
Connected to Azure db previously created couple years ago and has been in use.
"View Designer" was working initially.
Right before breaking, I just created a new column and new unique index to 3 tables.
Initially unable to "View Designer" on those tables, but able to on the other tables.
After several attempts, unable to "View Designer" on all tables with VS2017 and 2015.
Disconnected and reconnected with no success.
Restarting Visual Studio with no success.
Rebooting my system (running Visual Studio) appears to have fixed the problem.

My guess is some connection was held up... but doesn't make a lot of sense restarting application would fix that problem.

Friday, March 3, 2017

Javascript - Find elements by the "for" attribute

            function findLableForControl(el) {
                var idVal = el;
                labels = document.getElementsByTagName('label');
                for( var i = 0; i < labels.length; i++ ) {
                    if (labels[i].htmlFor == idVal)
                        return labels[i];

This function is handy when working with C# CheckBoxList (or really any of the C# lists). When creating javascript to manipulate the list, C# does not provide ID to the label, rows, nor columns. Thus to find the label, only the "for" attribute can be used to search.


C# DataBinding does not contain a property with the name with custom class object and CheckBoxList

I get the error "DataBinding: class1 does not contain a property with the name prop1"

public class1 {
  public string prop1;
  public string prop2;

My setup was an object array of class1 which has a property prop1 and prop2:

class1[] arrClass = new class1[arraySize];

Then I set the DataTextField and DataValue:
checkboxlist1.DataSource = arrClass;
checkboxlist1.DataTextField = "prop1";
checkboxlist1.DataValueField = "prop2";

This throws the error above. The fix is the lack of accessors in the class, class1. The class should be corrected to the following:
public class1 {
  public string prop1 { get; set; }
  public string prop2 { get; set; }
 Technically, set is not needed.