Learning WPF, CSharp(C#) with me | Part #2

December 6, 2017

Part #2

Subject: Why each trainer stick to console based development when my intention is to learn how to make “real” applications?

Hi guys,

Have you taken a training for development recently? If you are an established developer in any technology stack, the most frustrating thing could be the “basics”, you would groan and stir loads in the seat when a junior trainer goes through the concepts, basic commands set etc & would try to make the logic behind the approach

For example, if you want to learn C#, that you could use Web applications or desktop applications, you have a preset mind that wants to develop the applications those a user could interact with visibly. Not something that open a console and shows you few outputs and closes down.

I have asked the same question to many junior trainers during the courses and none was ever able to give me satisfactory answer. During my last attempt to refresh my C# skills I came to a conclusion towards this irritating question and it is simple like this

A console application when you want to print something on the screen, you just write a code snippet like this

static void Main(){

Console.WriteLine(“Hello World”);

}

And if you want to do the same with a Desktop application, the efforts are like this

You design a form (I will not use the real technical terms here, not at this stage)

You will add textboxes or labels to show “Hello World” (and you don’t really know how to make them at the first level)

Then you will develop the code part that should show the “Hello World” finally when the application starts

So for a trainer it becomes easy to deal with code part, which is the most important element of an application, rather than trying to teach a student the GUI development.

I will try to explain what I have assumed using real examples

Hellow World console application

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace HellowWorldConsole

{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hellow World");
}
}

}

Running the application will open a console window and show you the following

image

Now let us develop the same Hello World application using WPF

My GUI part has the following XAML Code

<Window x:Class="HelloWorldWPF.MainWindow"
xmlns="<a href="http://schemas.microsoft.com/winfx/2006/xaml/presentation"">http://schemas.microsoft.com/winfx/2006/xaml/presentation"</a>
xmlns:x="<a href="http://schemas.microsoft.com/winfx/2006/xaml"">http://schemas.microsoft.com/winfx/2006/xaml"</a>
Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
<Grid>
<TextBox x:Name="HWorld" Margin="95,150,117,124"/>
</Grid>

</Window>

and the code behind is


using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Data;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Imaging;

using System.Windows.Navigation;

using System.Windows.Shapes;

namespace HelloWorldWPF

{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}

private void Window_Loaded(object sender, RoutedEventArgs e)
{
this.HWorld.Text = "Hello World";
}
}

}

and the output of both portion is seen as below

image

Now, it’s a common tendency of a seasoned programmer to perfect the GUI, because it creates the initial appeal. As you could see my textbox and the text appearing is not in sync, the height of the textbox is much bigger than the text that it looks somewhat mismatch…the time spent to perfect the GUI could become a real hurdle to progress with the training which must be limited certain hours per course!

Instead the trainers would approach the course, trying to teach the student the maximum coding part, then once the students are familiar with the technology, letting them explore the GUI development (Unless the course has the GUI development exclusively listed under the curriculum)

Once the above idea settled within me comfortably, I managed to sit patiently and learn the “basics” better than ever & was able to map what I learned to GUI much easily. Interested? However, my approach with this series will be developing GUI elements along with the basic coding. Do you have a different approach? do let me know through comments.

with the 1st part of this series I have posted a complete WPF solution to demonstrate what C# with WPF could do. That solution has many issues, like I am not handling folder/file access permissions or threading which is a must requirement when a program is going to run for unprecedented periods.

Be with me and we will be looking at much of them in coming parts.

regards,

rajesh

Advertisements

Creating PDFs using Microsoft Word

August 13, 2017

Hi guys

Many great websites like “oracle base” let you copy the content from their site, so that you can make documents for offline references. Obviously, you need to copy, paste make sometimes format a bit here and there so that the document finally becomes worth keeping.

One of the major issues with most of the free PDF printers is the lack of ability to include the embedded urls. Once you find an interesting article and use a free PDF printer like “PDF Creator”, you will realize that whole the book marked urls are lost other than the links starting with http:// or www

With the recent versions of Microsoft Word software (Office 2010 & later) , Microsoft lets the users to save a word document as PDF, in addition to printing the documents as PDFs. So what are the main difference between printing and saving as a word document?

While printing, the engine discards all the embedded URLs and the end user gets a plain PDF file, and when saved as (From file Save as context) PDF, all underlying URLs are preserved as bookmarks and clickable links are created automatically.

Does it sounds interesting? Give it a try and let us know!

regards,

 


Windows | ORA-12560: TNS:protocol adapter error

February 25, 2017

Hi guys

Not many DBAs prefer Windows for their Oracle databases. Linux is most preferred by most of them & most of the DBAs I know setup the bash profile under Oracle user to setup the environment during each logon to the server.

Our legacy business application database runs on Windows 2003 & trust me, we never had a single database crash (Other than the physical hardware failure that forced us to recover the database once). Depending upon how huge the database and application, the choices for hosting the Oracle database differ from one business to other.

We decided to upgrade our Oracle 10g 10.1.x.x 32Bit database to 11g R2 & as usual I have replicated the environment using my home semi-server class desktop, before the Production environment at work.

Installed 10g 32Bit, created the database using dump export file (The total size of the database is less than 7GB, hence I avoided the hectic RMAN backup and restore part)

  1. Configured RMAN against the new database & made full backup for archive logs and database.
  2. Installed 11g 11.2.0.4 64Bit database (Software Only installation)
  3. Created a new Windows Service using oradim
  4. Restored the database from RMAN backups & upgraded the database to 11g

So far so good. I had to restart the computer & after rechecking the database was up and running, tried to access the instance using sqlplus & was presented with

ORA-12560: TNS:protocol adapter error

REG_SID_MISSING

I setup ORACLE_SID=SID at the CMD window & sqlplus was happy after that.

Usually, Windows doesn’t need environment variables set exclusively for the database as Windows registry takes care of it. This is very efficient when the box has only one database running. If you have more than one database or multiple Oracle homes, the scenario changes.

In addition to, Oracle always looks for the executable based on the PATH information it reads. For example my box has 10g,11g,12c database software installed without any databases created during the installation time.

Let us consider the scenario like I didn’t re-order the PATH entries after the latest installation of 12c & try to open SQL or RMAN. The call will find the executable from 12c path entry BIN as default, and a beginner could have enough confusions due to it.

In my case, I needed my 10g instance first, hence I moved the 10g folder as the 1st entry for Oracle products, and once I finished with 10g moved 11g home folder to the 1st position.

SID_Missing

Anyway, after confirming the path settings, my immediate attention was towards registry, as Oracle services completely depend upon the registry values for each service registered.

To my utter surprise, found the 11g Service entry didn’t have ORACLE_SID string created during the instance creation using ORADIM.exe

REG_SID_MISSING

Oracle 11g 11.2.0.4 has a huge bug list and interim patches those should be applied before moving to Production instance. I really don’t know whether the missing ORACLE_SID string entry was due to one of such bugs.

So I stopped the Oracle service, added ORACLE_SID string entry with the value for my database

REG_SID_ADD

Restarted the service & sqlplus connected to the instance happily without setting up the environment variable like set ORACLE_SID=SIDNAME

REG_SID_ADDED

While the easiest solution is to setup both ORACLE_HOME, ORACLE_SID when someone wants to use the sqlplus or RMAN exclusively as a part of the database access, the above method is a definite way to deal with “ORA-12560: TNS:protocol adapter error”

regards,

rajesh


Windows | ORA-06413: Connection not open

October 30, 2015

Hi guys

If you install a 32bit application in your 64bit Windows OS, following default prompts, the installed product will be under “<drive letter:>”\Program Files (x86)” & Oracle doesn’t really like those braces :)

You should uninstall the software and install it again in a folder that doesn’t have braces or spaces in between in it’s name

eg: C:\Program Files (x86)\some software to >> C:\somesoftware

Toad and few other little utilities available for Oracle will stop complaining about “ORA-06413: Connection not open” once after that.

 

for Windows7bugs

rajesh

 


Windows 10 64Bit | Install & Configure Weblogic 10.3.6 (64Bit), Developer Suite 11gR2 using JDK 7.x

October 8, 2015

Update (19th October 2015): I’m yet to find proper solutions for screen capturing in Windows 10. My favorite OBS doesn’t render the dropdown menus while screen recorded (thread here). Once it’s done, I will make the video as promised with my last update.

Update (12th October 2015) : I’m not promising, however, if possible, I will soon post a video with my Youtube channel explaining how you can configure both forms and reports server for hosting applications. Stay tuned :)

Hi guys

There are excellent articles explaining installing WebLogic 10.3.6 64Bit on Windows. Most of the installation methods are applicable to Windows 7, 8.x & on Windows 10 also. I opted to do a factory reset (the new reset option available with Windows 10) and was forced to re-install & configure WebLogic. I thought of sharing my experiences with you, as usual :)

(There were not a single hiccup experienced throughout the installation, to say it short)

Environment: Windows 10 Professional 64Bit, i5 Processor, 8GB memory, 1TB HDD, Dell laptop

Update 12th October 2015

Weblogic server 10.3.6 has identified issues with IPV6, hence I will suggest you to disable it in case if you are expecting a better experience with your Weblogic servers (forms & reports). ISA, the firewall client also could be a problem.

Once the IPV6 disabled, if you are in a home network or domain network, ping your machine and make sure that your ping replies are coming from your IPV4 address, instead of IPV6. If your computer is a domain member, ask your administrator to delete the IPV6 DNS entries for your box, disable IPV6 in your computer and restart. Ping again to confirm the replies are from IPV4. The issues are random, I had my Windows 8.1 machine with both the protocols enabled and my Weblogic servers just ran smoothly, however my Windows 10 box was adamant and until I disabled IPV6, couldn’t get the report server functional properly.

Step 1

Install JDK 7 to a folder without spaces in between, preferably C:\ (eg: C:\jdk or D:\jdk). Avoid installing JRE that comes with the JDK package.

Step 2

Copy your WebLogic installation .jar file to a folder (eg: D:\downloads)

Step 3

Now kick start the installation, as seen with the below image. It may take a while to deflate the .jar file and the installation to start

1

1a

2

Try to install the weblogic server in a folder that doesn’t have spaces in it’s name. I always installed it in D:\weblogic

3

You don’t have a support for the product most of the times, so uncheck the “I wish…”

4

5

6

7

8

Choose the “Typical” for install type

9

As you started the installation from the JDK installation folder, the local JDK will be already chosen

10

Select the defaults for components installations(unless you know how to handle it thoroughly)

11

Install WebLogic for all users

12

13

14

15

Uncheck “Run Quickstart” and exit the installation by clicking the Close button

16

Step 4 – Install Developer Suite 11gR2

Installation media for Developer Suite 11gR2 comes as 3 disks. Download (if still available) and start the “Setup.exe” from Disk 1

1

2

3

4

Select “Skip Software Updates” which requires a paid support from Oracle. If you have one, please set it up prior going ahead with the installation

5

Select “Install Software – Do Not Configure”. We’ll configure it as part of our Classic Instance setup.

6

You can ignore the error, details mentions about unsupported operating system, well that’s all our intentions

7

Unless you have specific requirements, accept the defaults

8

You don’t have a paid support from Oracle, you don’t get updates. Uncheck “I wish to …”

9

10

The installation will start now and it takes quite a while, in my case around 30 minutes. Sit back and relax

11

12

13

Exit the installation clicking “Finish” button.

14

Step 5 – Configure a Classic Instance

Even though you have installed Developer Suite 11gR2, you cannot yet use the development tools unless a classic domain is set up. Below please see how a classic domain is configured with Developer forms and reports.

A default installation of Oracle Developer Suite should create a folder “Oracle Classic 11g -Home1” under programs. You can activate the classic home setup by invoking menu item “Configure Classic Instance”

(I’m using ClassicShell start menu, I can’t really work with the latest “Start Menu”, so don’t get confused with the below image. You can use the search to find “Configure Classic Instance”)

0

0a

1

Select “Configure for Deployment”

2

Skip the below by unchecking the “I wish to …”

3

4

Unless mandatory, accept the defaults

5

Provide a alphanumeric password for “weblogic” account for the domain. Please note it down, incase if you fear of forgetting it (I do many times)

6

Important: By default “Oracle Forms and Reports 11g R2” is unchecked, You must check this option to install the developer tools. After checking, proceed with the configuration

7

Select “Auto Port Configuration”

8

Select “Do not use proxy settings”. Proxy settings could make weblogic experiences cumbersome. I suggest you use a computer that doesn’t require proxy settings

9

We are not going to use the Identity store for a local development machine, if you do, please provide the details.

10

Initiate the configurations by clicking “Configure” button

11

Configuration should complete in around 30 minutes, so sit back and relax

12

13

14

15

16

The above concludes the installation of WebLogic Server 10.3.6 & Developer Suite 11gR2 64Bit on Windows 10.

You can access the WebLogic server console by visiting http://localhost:7001/console/login/LoginForm.jsp

Let us checkout few essentials those will make sure that you have a seamless experience with the fresh installation.

Unlike the 32Bit, 64Bit installation of WebLogic server doesn’t install node manager Windows service. So you must install the windows service using the scripts provided by the installation process. If you didn’t change any of the default paths while installing the WebLogic server, the node manager windows service installation script file will be available …\wlserver_10.3\server\bin path

Best practice

Shutdown all running servers using the WebLogic console and restart the computer, this will avoid any sort of complication that could arise while the below exercise are executed.

From an elevated command prompt, running “installNodeMgrSvc.cmd” script will create this node manager windows service for you, which is mandatory for the WebLogic console to maintain your forms & reports servers (start, shutdown)

Once you created the node manager service, you should create a service for WebLogic admin server as well. This will help you from running the batch files manually & having a cluttered desktop later. More than, once created these services can restart themselves whenever you restart the box!

echo off
 
SETLOCAL
 
set DOMAIN_NAME=ClassicDomain
 
set USERDOMAIN_HOME=D:\WebLogic\user_projects\domains\ClassicDomain
 
set SERVER_NAME=AdminServer
 
set WL_HOME=D:\WebLogic\wlserver_10.3
 
set WLS_USER=weblogic
 
set WLS_PW=pass123
 
set PRODUCTION_MODE=true
 
set MEM_ARGS=-Xms512m -Xmx512m
 
call "%USERDOMAIN_HOME%\bin\setDomainEnv.cmd" 
 
call "%WL_HOME%\server\bin\installSvc.cmd"
 
ENDLOCAL

Copy the above script to a text file and save with a name like “InstallAdminServer.cmd” or with a name that ends with .cmd extension. I will always prefer saving the file in the same folder where we had the node manager service installation script.

Now, from an elevated command prompt, run the script, which should create Admin Server Windows Service for you.

srvc

If you followed the instructions, you should see all the services as listed above. You can start the ones which are not running, Please wait a while before trying to access the WebLogic admin console after starting the service. It takes few minutes for the admin server to come online.

I do hope this post will help you to install and configure WebLogic Server and Developer Suite 11gR12 on Windows 10 successfully. Have questions or problems? please update me with the comment section.

for Windows7bugs

rajesh


Weblogic Server 10.3.6 64Bit on Windows | Difference between 32Bit Installation(s)

January 24, 2015

https://windows7bugs.wordpress.com/2013/04/06/install-configure-oracle-weblogic-server-10-3-6-forms-reports-11g-on-windows8windows-2008-r2/

Was one of our maximum sought posts & recently I decided to go for a fresh installation of Weblogic 10.3.6 64Bit installation + Forms & reports 11g R2 64Bit. We repeat one of the best articles explain how to is available here and what we are going to provide you additional is few of the things those are different from a typical 32Bit installation.

JDK 8 is not supported (Or my two attempts didn’t bring any fruits)

Node Manager Windows service installation is not offered during the normal/custom installations. That means you MUST install the node manager service by running the .cmd file provided. Default location for the .cmd file is …\wlserver_10.3\server\bin and the file name is “installNodeMgrSvc.cmd”. You should execute this .cmd file from an elevated command prompt!

If you prefer to install a service for Admin server, we have altered the script a little bit and please find it below.

echo off

SETLOCAL

set DOMAIN_NAME=ClassicDomain

set USERDOMAIN_HOME=D:\WebLogic\user_projects\domains\ClassicDomain

set SERVER_NAME=AdminServer

set WL_HOME=D:\WebLogic\wlserver_10.3

set WLS_USER=weblogic

set WLS_PW=pass123

set PRODUCTION_MODE=true

set MEM_ARGS=-Xms512m -Xmx512m

call "%USERDOMAIN_HOME%\bin\setDomainEnv.cmd" 

call "%WL_HOME%\server\bin\installSvc.cmd"

ENDLOCAL

I really hope the above tips will make your Weblogic installation more enjoyable.

regards,

rajesh


Install Oracle 10g (10.2.0.3 onwards) on Windows 10 (Technical Preview)

October 6, 2014

We know it is too early, still as usual we are kicking in once again trying to install Oracle 10g onwards databases on an OS that’s in the early stages of testing/improvements.

If you are wondering whether Oracle 10g (10.2.0.3 onwards) could be installed on Windows 10 (TP), the shortest answer is yes and as usual the earlier hacks what we specified with https://windows7bugs.wordpress.com/2010/02/18/install-oracle-10g-onward-database-developer-on-windows-7/ are still valid for the installation on Windows 10 TP

All you need to do is to add an entry to the refhost.xml file like following:

<CERTIFIED_SYSTEMS>
<OPERATING_SYSTEM>
<VERSION VALUE=”5.0″/>
<SERVICE_PACK VALUE=”1″/>
</OPERATING_SYSTEM>
<OPERATING_SYSTEM>
<VERSION VALUE=”5.1″/>
<SERVICE_PACK VALUE=”1″/>
</OPERATING_SYSTEM>
<OPERATING_SYSTEM>
<VERSION VALUE=”5.2″/>
</OPERATING_SYSTEM>
<!–Microsoft Windows Vista–>
<OPERATING_SYSTEM>
<VERSION VALUE=”6.0″/>
</OPERATING_SYSTEM>
<!–Microsoft Windows 7–>
<OPERATING_SYSTEM>
<VERSION VALUE=”6.1″/>
</OPERATING_SYSTEM>
<!–Microsoft Windows 8–>
<OPERATING_SYSTEM>
<VERSION VALUE=”6.2″/>
</OPERATING_SYSTEM>
 <!–Microsoft Windows 10–>
    <OPERATING_SYSTEM>
      <VERSION VALUE=”6.4″/>
    </OPERATING_SYSTEM>
</CERTIFIED_SYSTEMS>

You may safely ignore the warnings (if any) and proceed with the Installation. Please note, as usual we warn you not to install unsupported databases on newer Operating Systems as you may risk with your valued data. Below, few screen shots from our installation attempt which was successful.

1

2

3

You will be prompted to install .NET Framework 3.5 (That includes .NET 2.0 and 3.0), and we suggest you install it for better stability of the database

4

6

7

8

That’s all folks

for Windows7bugs

rajesh