Tag Archives: Common Exception Handling

Abnormal [System.InvalidOperationException: custom type mapping for ‘xxx’ is not specified or is not a solution

In the use of C # code to get data from Oracle database, but because it is an object-oriented way, the model object in C # is also established in Oracle, and the corresponding mapping should be done in the Oracle connection code of C #.

When running, this exception is thrown:

ex=System.InvalidOperationException: Custom type mapping not specified with 'dataSource='xxxxxxx' schemaName='xxx' typeName='xxx' or the mapping is invalid
   at Oracle.DataAccess.Types.OracleUdt.GetFactory(OracleUdtDescriptor udtDesc)
   at Oracle.DataAccess.Client.OracleParameter.SetUDTFromArray(OracleConnection conn, Object array, Int32 i)
   at Oracle.DataAccess.Client.OracleParameter.PreBind_Collection(OracleConnection conn)
   at Oracle.DataAccess.Client.OracleParameter.PreBind(OracleConnection conn, IntPtr errCtx, Int32 arraySize)
   at Oracle.DataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior)
   at Oracle.DataAccess.Client.OracleDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
   at HCC.Base.Comm.Dao.OraHelper.ExecuteDataTableSp(String dbkey, String procName, List`1 prams) 

Through various searches, it is found that the source of the problem lies in accidentally writing the udttypename wrong in the mapping code, which leads to this exception. Correct the spelling of udttypename to make the code work properly.

 

[Solved] ORA-21525: attribute number or (collection element at index) string violated its constraints

Exception: 

ORA-21525: attribute number or (collection element at index) string violated its constraints

Cause: Attribute value or collection element value violated its constraint.

Action: Change the value of the attribute or collection element such that it meets its constraints. The constraints are specified as part of the attribute or collection element’s schema information.

 

Error reason:

When passing data to stored procedures in C #, the user-defined object of Oracle is used. However, when passing in, some obj fields will throw this exception if the length of the value finally passed in is greater than that of the type definition. For example, this time type number (3) was passed in 1100

 

as like as two peas, it will probably have other problems, and it will also throw out this exception, which is not exactly the same as this encounter, but as a reference for solving problems.

[Solved] The type or namespace name ‘Service’ does not exist Error

The reason for this exception may be that the corresponding assembly is not introduced into the project. Generally speaking, the problem is solved after the required assembly is introduced. Sometimes there is a strange problem. For example, project B is a class library. Project a refers to the class of project B, such as userservice. Project B is also introduced into the reference of project A. However, when compiling in project a, an error is reported, saying that the type or namespace name ‘userservice’ does not exist in the namespace ‘xxx’ (are you missing an assembly reference?)

Now, for example, is there anything related to warning

The referenced assembly ” XXX.Service.dll ” could not be resolved because it has a dependency on ” System.ServiceModel.Web , Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ which is not in the currently targeted framework “.NETFramework,Version=v4.0, Profile=Client”. Please remove references to assemblies not in the targeted framework or consider retargeting your project.

That is to say, because the Framework version used by project a and project B is different, the class of a cannot be used in project B. At this point, as long as the Framework version of the project is reset to make the two projects consistent, the problem is solved.

[Solved] Running in 64 bit mode with the 32 bit Oracle client installed

When connecting to Oracle database, it is easy to encounter the problem of 32-bit and 64 bit drivers. On a 32-bit machine, everything is 32-bit, which is not complicated. But now the general win7 system is 64 bit, and 64 bit machine can install 32-bit and 64 bit driver.

 

If the WinForm program is used to connect to Oracle database, you can use Oracle’s own DLL, Oracle.DataAcess , you can also use Microsoft’s own System.Data.OracleClient . But the premise of using these two days is that the Oracle client driver must be installed on the machine. The driver here is divided into 32-bit and 64 bit. and Oracle.DataAcess Also divided into 32-bit and 64 bit, which must be consistent before and after the two.

Let’s talk about the recent problems. Recently, I’m working on a website project. Note that it’s not a web application, it’s just a website project, and it’s directly published to IIS. It’s just Microsoft ystem.Data.OracleClient The build mode of the project is any CPU, as shown in the figure below.

 

 

Because vs has its own Cassini server only in 32-bit mode, the programs in any CPU mode can only run in 32-bit mode. At this time, an exception running in 64 bit mode with the 32 bit Oracle client installed is reported System.Data.OracleClient The version of 32 or 64 is not right. Many changes have been made, but the reason has not been found out. Later, I understood that the 32 bit Oracle client installed here refers to the DLL, not the driver downloaded from the Oracle official website. Because at this time, only ORALCE’s 64 bit driver is installed on my machine. Now this program is 32-bit. When I connect to the 64 bit driver, this exception is reported. When I installed the 32-bit Oracle driver, this problem was solved.

 

I also encountered a small problem during the installation, because I have installed 64 bit driver before, and there is an Oracle app directory in the machine. At this time, we can install the 32-bit driver into the custom directory app2. In other words, 32-bit and 64 bit Oracle client drivers are installed on the machine at the same time. The program will connect to the corresponding driver according to its own x86 or x64 mode, and then connect to the Oracle database remotely. Note that the driver for installing Oracle client is the machine where the DLL is located, that is, the machine where the program runs, not the machine where the Oracle server is located. In essence, Oracle client and Oracle server transmit data on the network.

 

 

 

 

 

 

The execution of ExecuteNonQuery by oraclecommand is suspended

string sql = "INSERT INTO TempTable (A, B, C) VALUES ('2222222', '1111111', 'RRR')";
OracleCommand cmd = new OracleCommand(sql, connection);
cmd.ExecuteNonQuery();

 

When executing this code, the first insertion failed. When stop debug restarts, it is found that the program runs to cmd.ExecuteNonQuery It’s stuck when I’m in. The reason for this is Oracle’s block mechanism.

If session “A” inserts a row in a table with a primary key, session “A” will block ANY other session attempting to insert the same primary key until session “A” commits or rolls back the insert. All other attempts to insert will “hang”.

At this point, I change the primary key 2222222 of SQL statement into 33333333 in the code, and then I can insert it smoothly. This indicates that this operation will be blocked only when the primary key is the same. Because when 2222222 was inserted, the program ended unexpectedly, but the Oracle transaction was not committed or rolled back, so this primary key was locked. Note that it’s just the primary key of this value.

there is another problem here, that is, when I open SQL developer and execute the primary key statement of 2222222, the execution will be completed smoothly without blocking. Now, when I execute SQL statements with code, the blocking phenomenon will still occur. But when I restart vs, create a new project and write these codes, it is also equivalent to another program to execute the insert statement, which will also get stuck. May be related to the. Net provider used?Because you are using the same provider, it is stuck. Because SQL developer doesn’t use this provider, it won’t get stuck?It’s just a guess.

This kind of lock is called tmlock, or row transaction lock. You can use SQL statements to check whether there is such a lock
or not

SELECT sid, id1 FROM v$lock WHERE TYPE=’TM’

SID ID1
76 14197

SELECT * FROM dba_ objects WHERE object_ id = 14197;

OBJECT_ NAME
——————————————————————————————————————————–
TemTable

 

How to release this TM lock?row transaction lock

Just execute a commit command in the SQL developer UI.

The page you are requesting cannot be served because of the extension configuration

In deployment ASP.NET When the website is deployed to IIS, visit the page http://localhost/UserCenter/user.aspx , but an exception was thrown. At this time, to detect whether the deployment is successful, you can write a text file for testing in the root directory text.txt , and then access the file http://localhost/UserCenter/test.txt If you can see the contents of this file, it means that there is no problem with the deployment. Maybe there is a problem with the code.

 

Abnormal prompt:

HTTP error 404.3 – not found
the page you are asking cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a mime map.

abnormal screenshot

 

The reason for this problem is that there are multiple. Net versions on the machine, so there are multiple ASP.NET Version. Now our application pool is in version 4.0, but this version is not registered in IIS, so this error is reported. Now what we need to do is register the 4.0 ASP.NET Version. In C: windows\ Microsoft.NET \Find IIS registration tools, namely aspnet, in the directory of framework64/v4.0.xxxx_ regiis.exe Then start it in the form of a DOS window, aspnet_ Regiis – I refer to MSDN for details http://msdn.microsoft.com/en-us/library/k6h9cz8h%28VS.80%29.aspx

Running results

 

At this point, restart the application pool and website, and you can see the normal ASPX rendered page.

 

Springboot + mybatis + logback does not print SQL problems on the console

This project uses springboot + mybatis + logback. In order to print SQL on the console, various configurations have been made in the configuration file. All the methods available on the Internet have been tried, but SQL statements are still not printed.

This is indicated in the configuration file logging.level.cn . homecredit.sams.ddme . reconciliation.model.mapper=debug . still do not print SQL statements.

Another SpringBoot project, as like as two peas, is able to print SQL statements on the console. By comparing the differences between the two projects step by step, it is found that the project can be printed after the histrix package is introduced.

<dependency>
     <groupId>org.springframework.cloud</groupId>
     <artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>

 

 

In the end, I don’t know what the reason is, but after introducing this package, the problem is solved.

Note that this is only one of the possible reasons for this problem. In addition, there are many other problems that may result in the inability to print SQL on the console. You need to configure every step.

 

Solve the problem of incomplete search results of outlook search function

Recently, when I used outlook, I found that the search results were always limited to a certain date when I searched e-mail in my inboxes according to the keywords of people’s names, and the search results were not complete at all.

The solution is to go to the file – & gt; Options tab, select search in the pop-up dialog box, then select index option, and then remove the check mark of Microsoft Outlook options in the moidfy dialog box.

After the setting is completed, the search should be conducted according to the keyword of the person’s name, which should be the complete result.

 

Then I thought, why?Because it could be. When we select Microsoft Outlook in the index options dialog box, that is to say, windows will index the files in outlook. When we use Outlook to search, outlook finds that it is in the index category, so it will look for things in the index directory, and the index directory is not up-to-date, which directly leads to incomplete search results.

 

If we remove the index option of outlook, outlook finds that it is not in the index category when searching, and will directly search all the files in outlook according to its own algorithm instead of in the index directory, so the result will be very complete and accurate.

 

In summary, the purpose of index is to speed up the search speed, but if the index directory is not updated in time, it will cause the incompleteness of the search results.

From personal blog: http://www.sunrobin.net

Ajax can’t download file to browser

Recently, I encountered such a function when I was working on a website. In the page as shown in the figure, when users need to click the link, they can judge whether the corresponding excel file is stored in the server in an asynchronous ajax way. If not, they will be prompted that they have not found it, and if so, they will download it to the local user.

 

Of course, this is a very simple problem. Just write Ajax in a normal way. But when the server returns the file content to the browser in binary form, the browser’s Ajax throws an error. It’s about parseError, invalid XML, PK, etc.

 

 

The reason for this problem is not that there is a problem with the server-side code or JavaScript code, but that downloading files through AJAX is forbidden. For security reasons, JavaScript is not able to save the file to the local, so Ajax takes this into account. It only accepts the return value in XML, Ajax and JSON format, and the binary return format will throw this exception.

 

How to solve this problem?use window.location =URL is OK. Some people will ask, such as the above figure, when you click the download link on a certain page, because it has changed window.location Is the current page about to jump?In fact, I use Chrome browser. When I click that link, the next file save dialog box will pop up directly, and the address bar of the page has no change. At this time, if you click save, the file will be kept. If you click cacel, the operation will be cancelled. During the process, the current page will be kept and will not jump to other pages.

 

 

From personal blog www.sunrobin.net

 

 

The requested page cannot be accessed because the related configuration data for the page is invalid

In the development process, IIS express is used to debug the web program. When there is a problem when opening the website, the following page will be displayed. The reason for this problem is that the website may be Web.config The control of access rights in IIS express is different from that of IIS express itself application.host There is a problem with the configuration in. What we need to do now is to find the conflicting configuration according to the prompt. Here is the authentication configuration. The configuration is in my documents/iisexpress/config. The specific path may change, but the configuration file is usually installed in my documents during installation.

According to the tips on the page, after modifying the conflicting configuration, there will be no problem in accessing the website.

Take this problem as an example, here is because of access rights conflict, so just change it.

Abnormal display of page object moved to here

When using Response.Redirect () method, if null or “” is passed in, object moved to here will be displayed on the page. There are only these letters object moved to here on a blank page. This is because the server returns a

The 302 command asks to jump again, but it doesn’t send the URL to jump. The browser doesn’t know where to jump, so the browser displays these letters.

Solution to server application error in IIS 5.1

Error message:

Server Application Error 
The server has encountered an error while loading an application during the processing of your request. Please refer to the event log for more detail information. Please contact the server administrator for assistance.

terms of settlement:

[1]
check whether your DTC service (full name: Distributed Transaction Coordinator) can start normally. If it is normal, please skip this step. If it fails to start normally, please run: MSDTC – resetlog in the start menu to create the log file. Restart the machine and check whether IIS can be used normally. If not, continue.

[2]:
execute the following command under CMD:
CD% windir% \ system32 \ \ inetsrv

rundll32 wamreg.dll , CreateIISPackage 

regsvr32 asptxn.dll

I can use it here. Now open IIS and visit the corresponding page.